Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2022-11-29 03:53:21
Exec Total Coverage
Lines: 6816 11431 59.6%
Functions: 66 105 62.9%
Branches: 4163 9893 42.1%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #ifndef __GTHREAD_HIDE_WIN32API
12 #define __GTHREAD_HIDE_WIN32API 1
13 #endif //prevent indirectly including windows.h
14
15 #include "precompiled.h" //always first
16 11
17 #include <stdio.h>
18 #include <string.h>
19 #include <string>
20 #include <map>
21 #include <vector>
22 #include <assert.h>
23
24
25 #include "metadata/sigs/devsig.h.sig"
26 #include "metadata/sigs/compilersig.h.sig"
27 #include "metadata/versionsig.h"
28 #include "base/zc_alleg.h"
29 #include "base/zdefs.h"
30 #include "base/colors.h"
31 #include "tiles.h"
32 #include "base/zsys.h"
33 #include "qst.h"
34 //#include "zquest.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "font.h"
38 #include "zc_custom.h"
39 #include "sfx.h"
40 #include "md5.h"
41 #include "ffscript.h"
42 #include "particles.h"
43 #include "dialog/alert.h"
44 //FFScript FFCore;
45 extern FFScript FFCore;
46 extern ZModule zcm;
47 extern zcmodule moduledata;
48 extern uint8_t __isZQuest;
49 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
50 extern particle_list particles;
51 extern void setZScriptVersion(int32_t s_version);
52 //FFSCript FFEngine;
53
54 int32_t temp_ffscript_version = 0;
55 static bool read_ext_zinfo = false, read_zinfo = false;
56 static bool loadquest_report = false;
57 static char const* loading_qst_name = NULL;
58 static byte loading_qst_num = 0;
59
60 #ifdef _MSC_VER
61 #define strncasecmp _strnicmp
62 #endif
63
64 #ifndef _AL_MALLOC
65 #define _AL_MALLOC(a) _al_malloc(a)
66 #define _AL_FREE(a) _al_free(a)
67 #endif
68
69 using std::string;
70 using std::pair;
71
72 // extern bool debug;
73 extern int32_t hero_animation_speed; //lower is faster animation
74 extern std::vector<mapscr> TheMaps;
75 extern zcmap *ZCMaps;
76 extern MsgStr *MsgStrings;
77 extern DoorComboSet *DoorComboSets;
78 extern dmap *DMaps;
79 extern newcombo *combobuf;
80 extern byte *colordata;
81 //extern byte *tilebuf;
82 extern tiledata *newtilebuf;
83 extern byte *trashbuf;
84 extern itemdata *itemsbuf;
85 extern wpndata *wpnsbuf;
86 extern comboclass *combo_class_buf;
87 extern guydata *guysbuf;
88 extern ZCHEATS zcheats;
89 extern zinitdata zinit;
90 extern char palnames[MAXLEVELS][17];
91 extern int32_t memrequested;
92 extern char *byte_conversion(int32_t number, int32_t format);
93 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
94 11 string zScript;
95 11 std::map<int32_t, script_slot_data > ffcmap;
96 11 std::map<int32_t, script_slot_data > globalmap;
97 11 std::map<int32_t, script_slot_data > genericmap;
98 11 std::map<int32_t, script_slot_data > itemmap;
99 11 std::map<int32_t, script_slot_data > npcmap;
100 11 std::map<int32_t, script_slot_data > ewpnmap;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
22 std::map<int32_t, script_slot_data > lwpnmap;
102 11 std::map<int32_t, script_slot_data > playermap;
103 11 std::map<int32_t, script_slot_data > dmapmap;
104 11 std::map<int32_t, script_slot_data > screenmap;
105 11 std::map<int32_t, script_slot_data > itemspritemap;
106 11 std::map<int32_t, script_slot_data > comboscriptmap;
107 void free_newtilebuf();
108 bool combosread=false;
109 bool mapsread=false;
110 bool fixffcs=false;
111 bool fixpolsvoice=false;
112
113 11 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
114 11 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
115 11 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
116 11 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
117
118 char qstdat_string[2048] = { 0 };
119
120 static zinfo* load_tmp_zi = NULL;
121
122 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
123 const byte clavio[9]={97,109,111,110,103,117,115,0};
124
125 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
126 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
127
128 extern combo_alias combo_aliases[MAXCOMBOALIASES];
129 extern combo_pool combo_pools[MAXCOMBOPOOLS];
130 const char *qst_error[] =
131 {
132 "OK","File not found","Invalid quest file",
133 "Version not supported","Obsolete version",
134 "Missing new data" , /* but let it pass in ZQuest */
135 "Internal error occurred", "Invalid password",
136 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
137 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
138 };
139
140 //for legacy quests -DD
141 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
142 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
143 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDINSFIRE, ssiFARORESWIND, ssiNAYRUSLOVE, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
144 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
145 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
146 };
147
148 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
149
150
151 void delete_combo_aliases()
152 {
153 for(int32_t j(0); j<256; j++)
154 {
155 if(combo_aliases[j].combos != NULL)
156 {
157 delete[] combo_aliases[j].combos;
158 combo_aliases[j].combos=NULL;
159 }
160
161 if(combo_aliases[j].csets != NULL)
162 {
163 delete[] combo_aliases[j].csets;
164 combo_aliases[j].csets=NULL;
165 }
166 }
167
168 }
169
170 char *byte_conversion(int32_t number, int32_t format)
171 {
172 static char num_str[40];
173
174 if(format==-1) //auto
175 {
176 format=1; //bytes
177
178 if(number>1024)
179 {
180 format=2; //kilobytes
181 }
182
183 if(number>1024*1024)
184 {
185 format=3; //megabytes
186 }
187
188 if(number>1024*1024*1024)
189 {
190 format=4; //gigabytes (dude, what are you doing?)
191 }
192 }
193
194 switch(format)
195 {
196 case 1: //bytes
197 sprintf(num_str,"%db",number);
198 break;
199
200 case 2: //kilobytes
201 sprintf(num_str,"%.2fk",float(number)/1024);
202 break;
203
204 case 3: //megabytes
205 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
206 break;
207
208 case 4: //gigabytes
209 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
210 break;
211
212 default:
213 exit(1);
214 break;
215 }
216
217 return num_str;
218 }
219
220 154 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
221 {
222 static char num_str1[40];
223 static char num_str2[40];
224 static char num_str[80];
225
226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if(format1==-1) //auto
227 {
228 154 format1=1; //bytes
229
230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if(number1>1024)
231 {
232 154 format1=2; //kilobytes
233 154 }
234
235
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 44 times.
154 if(number1>1024*1024)
236 {
237 44 format1=3; //megabytes
238 44 }
239
240
1/2
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
154 if(number1>1024*1024*1024)
241 {
242 format1=4; //gigabytes (dude, what are you doing?)
243 }
244 154 }
245
246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if(format2==-1) //auto
247 {
248 154 format2=1; //bytes
249
250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if(number2>1024)
251 {
252 154 format2=2; //kilobytes
253 154 }
254
255
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 143 times.
154 if(number2>1024*1024)
256 {
257 143 format2=3; //megabytes
258 143 }
259
260
1/2
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
154 if(number2>1024*1024*1024)
261 {
262 format2=4; //gigabytes (dude, what are you doing?)
263 }
264 154 }
265
266
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
154 switch(format1)
267 {
268 case 1: //bytes
269 sprintf(num_str1,"%db",number1);
270 break;
271
272 case 2: //kilobytes
273 110 sprintf(num_str1,"%.2fk",float(number1)/1024);
274 110 break;
275
276 case 3: //megabytes
277 44 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
278 44 break;
279
280 case 4: //gigabytes
281 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
282 break;
283
284 default:
285 exit(1);
286 break;
287 }
288
289
2/5
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 143 times.
✗ Branch 4 not taken.
154 switch(format2)
290 {
291 case 1: //bytes
292 sprintf(num_str2,"%db",number2);
293 break;
294
295 case 2: //kilobytes
296 11 sprintf(num_str2,"%.2fk",float(number2)/1024);
297 11 break;
298
299 case 3: //megabytes
300 143 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
301 143 break;
302
303 case 4: //gigabytes
304 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
305 break;
306
307 default:
308 exit(1);
309 break;
310 }
311
312 154 sprintf(num_str, "%s/%s", num_str1, num_str2);
313 154 return num_str;
314 }
315
316 char *ordinal(int32_t num)
317 {
318 static const char *ending[4] = {"st","nd","rd","th"};
319 static char ord_str[8];
320
321 char *end;
322 int32_t t=(num%100)/10;
323 int32_t n=num%10;
324
325 if(n>=1 && n<4 && t!=1)
326 end = (char *)ending[n-1];
327 else
328 end = (char *)ending[3];
329
330 sprintf(ord_str,"%d%s",num%10000,end);
331 return ord_str;
332 }
333
334 11 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
335 {
336 int32_t ret;
337 11 *version=0;
338 11 *build=0;
339 11 byte temp_map_count=map_count;
340 byte temp_midi_flags[MIDIFLAGS_SIZE];
341 11 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
342
343 zquestheader tempheader;
344
345
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!f)
346 {
347 return qe_invalid;
348 }
349
350 11 ret=readheader(f, &tempheader, true);
351
352
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(ret)
353 {
354 return ret;
355 }
356
357 11 map_count=temp_map_count;
358 11 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
359 11 *version=tempheader.zelda_version;
360 11 *build=tempheader.build;
361 11 return 0;
362 11 }
363
364
365 11 bool find_section(PACKFILE *f, int32_t section_id_requested)
366 {
367
368
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!f)
369 {
370 return false;
371 }
372
373 int32_t section_id_read;
374 11 bool catchup=false;
375 word dummy;
376 byte tempbyte;
377 char tempbuf[65536];
378
379
380
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 switch(section_id_requested)
381 {
382 case ID_RULES:
383 case ID_STRINGS:
384 case ID_MISC:
385 case ID_TILES:
386 case ID_COMBOS:
387 case ID_CSETS:
388 case ID_MAPS:
389 case ID_DMAPS:
390 case ID_DOORS:
391 case ID_ITEMS:
392 case ID_WEAPONS:
393 case ID_COLORS:
394 case ID_ICONS:
395 case ID_INITDATA:
396 case ID_GUYS:
397 case ID_MIDIS:
398 case ID_CHEATS:
399 11 break;
400
401 default:
402 al_trace("Bad section requested!\n");
403 return false;
404 break;
405 }
406
407 dword section_size;
408
409 //section id
410
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_mgetl(&section_id_read,f,true))
411 {
412 return false;
413 }
414
415
1/2
✓ Branch 0 taken 2244 times.
✗ Branch 1 not taken.
2244 while(!pack_feof(f))
416 {
417
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2233 times.
2244 switch(section_id_read)
418 {
419 case ID_RULES:
420 case ID_STRINGS:
421 case ID_MISC:
422 case ID_TILES:
423 case ID_COMBOS:
424 case ID_CSETS:
425 case ID_MAPS:
426 case ID_DMAPS:
427 case ID_DOORS:
428 case ID_ITEMS:
429 case ID_WEAPONS:
430 case ID_COLORS:
431 case ID_ICONS:
432 case ID_INITDATA:
433 case ID_GUYS:
434 case ID_MIDIS:
435 case ID_CHEATS:
436 11 catchup=false;
437 11 break;
438
439 default:
440 2233 break;
441 }
442
443
444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2244 times.
2244 while(catchup)
445 {
446 //section id
447 section_id_read=(section_id_read<<8);
448
449 if(!p_getc(&tempbyte,f,true))
450 {
451 return false;
452 }
453
454 section_id_read+=tempbyte;
455 }
456
457
1/2
✓ Branch 0 taken 2244 times.
✗ Branch 1 not taken.
2244 if(section_id_read==section_id_requested)
458 {
459 return true;
460 }
461 else
462 {
463 //section version info
464
1/2
✓ Branch 0 taken 2244 times.
✗ Branch 1 not taken.
2244 if(!p_igetw(&dummy,f,true))
465 {
466 return false;
467 }
468
469
1/2
✓ Branch 0 taken 2244 times.
✗ Branch 1 not taken.
2244 if(!p_igetw(&dummy,f,true))
470 {
471 return false;
472 }
473
474 //section size
475
1/2
✓ Branch 0 taken 2244 times.
✗ Branch 1 not taken.
2244 if(!p_igetl(&section_size,f,true))
476 {
477 return false;
478 }
479
480 //pack_fseek(f, section_size);
481
2/2
✓ Branch 0 taken 720885 times.
✓ Branch 1 taken 2244 times.
723129 while(section_size>65535)
482 {
483 720885 pfread(tempbuf,65535,f,true);
484 720885 tempbuf[65535]=0;
485 720885 section_size-=65535;
486 }
487
488
2/2
✓ Branch 0 taken 2189 times.
✓ Branch 1 taken 55 times.
2244 if(section_size>0)
489 {
490 55 pfread(tempbuf,section_size,f,true);
491 55 tempbuf[section_size]=0;
492 55 }
493 }
494
495 //section id
496
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2233 times.
2244 if(!p_mgetl(&section_id_read,f,true))
497 {
498 11 return false;
499 }
500 }
501
502 return false;
503 11 }
504
505
506
507
508
509 11 bool valid_zqt(PACKFILE *f)
510 {
511
512 //word tiles_used;
513 //word combos_used;
514 //open the file
515 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!f)
517 return false;
518
519 //for now, everything else is valid
520 11 return true;
521
522 /*int16_t version;
523 byte build;
524
525 //read the version and make sure it worked
526 if(!p_igetw(&version,f,true))
527 {
528 goto error;
529 }
530
531 //read the build and make sure it worked
532 if(!p_getc(&build,f,true))
533 goto error;
534
535 //read the tile info and make sure it worked
536 if(!p_igetw(&tiles_used,f,true))
537 {
538 goto error;
539 }
540
541 for (int32_t i=0; i<tiles_used; i++)
542 {
543 if(!pfread(trashbuf,tilesize(tf4Bit),f,true))
544 {
545 goto error;
546 }
547 }
548
549 //read the combo info and make sure it worked
550 if(!p_igetw(&combos_used,f,true))
551 {
552 goto error;
553 }
554 for (int32_t i=0; i<combos_used; i++)
555 {
556 if(!pfread(trashbuf,sizeof(newcombo),f,true))
557 {
558 goto error;
559 }
560 }
561
562 //read the palette info and make sure it worked
563 for (int32_t i=0; i<48; i++)
564 {
565 if(!pfread(trashbuf,newpdTOTAL,f,true))
566 {
567 goto error;
568 }
569 }
570 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f,true))
571 {
572 goto error;
573 }
574 for (int32_t i=0; i<MAXLEVELS; i++)
575 {
576 if(!pfread(trashbuf,PALNAMESIZE,f,true))
577 {
578 goto error;
579 }
580 }
581
582 //read the sprite info and make sure it worked
583 for (int32_t i=0; i<MAXITEMS; i++)
584 {
585 if(!pfread(trashbuf,sizeof(itemdata),f,true))
586 {
587 goto error;
588 }
589 }
590
591 for (int32_t i=0; i<MAXWPNS; i++)
592 {
593 if(!pfread(trashbuf,sizeof(wpndata),f,true))
594 {
595 goto error;
596 }
597 }
598
599 //read the triforce pieces info and make sure it worked
600 for (int32_t i=0; i<8; ++i)
601 {
602 if(!p_getc(&trashbuf,f,true))
603 {
604 goto error;
605 }
606 }
607
608
609
610 //read the game icons info and make sure it worked
611 for (int32_t i=0; i<4; ++i)
612 {
613 if(!p_igetw(&trashbuf,f,true))
614 {
615 goto error;
616 }
617 }
618
619 //read the misc colors info and map styles info and make sure it worked
620 if(!pfread(trashbuf,sizeof(zcolors),f,true))
621 {
622 goto error;
623 }
624
625 //read the template screens and make sure it worked
626 byte num_maps;
627 if(!p_getc(&num_maps,f,true))
628 {
629 goto error;
630 }
631 for (int32_t i=0; i<TEMPLATES; i++)
632 {
633 if(!pfread(trashbuf,sizeof(mapscr),f,true))
634 {
635 goto error;
636 }
637 }
638 if (num_maps>1) //dungeon templates
639 {
640 for (int32_t i=0; i<TEMPLATES; i++)
641 {
642 if(!pfread(trashbuf,sizeof(mapscr),f,true))
643 {
644 goto error;
645 }
646 }
647 }
648
649 //yay! it worked! close the file and say everything was ok.
650 pack_fclose(f);
651 return true;
652
653 error:
654 pack_fclose(f);
655 return false;*/
656 11 }
657
658 bool valid_zqt(const char *filename)
659 {
660 PACKFILE *f=NULL;
661 bool isvalid;
662 char deletefilename[1024];
663 deletefilename[0]=0;
664 int32_t error;
665 f=open_quest_file(&error, filename, deletefilename, true, true,false);
666
667 if(!f)
668 {
669 // setPackfilePassword(NULL);
670 return false;
671 }
672
673 isvalid=valid_zqt(f);
674
675 if(deletefilename[0])
676 {
677 delete_file(deletefilename);
678 }
679
680 // setPackfilePassword(NULL);
681 return isvalid;
682 }
683
684 24 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, char *deletefilename, bool compressed,bool encrypted, bool show_progress)
685 {
686 char tmpfilename[L_tmpnam];
687 24 temp_name(tmpfilename);
688 char percent_done[30];
689 24 int32_t current_method=0;
690
691 PACKFILE *f;
692 24 const char *passwd= encrypted ? datapwd : "";
693
694 // oldquest flag is set when an unencrypted qst file is suspected.
695 24 bool oldquest = false;
696 int32_t ret;
697
698
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(show_progress)
699 {
700 box_start(1, "Loading Quest", lfont, font, true);
701 }
702
703 24 box_out("Loading Quest: ");
704 //if(strncasecmp(filename, "qst.dat", 7)!=0)
705 //int32_t qstdat_str_size = 0;
706 //for ( int32_t q = 0; q < 255; q++ ) //find the length of the string
707 //{
708 // if ( moduledata.datafiles[qst_dat][q] != 0 ) qstdat_str_size++;
709 // else break;
710 //}
711 //if(strncasecmp(filename, moduledata.datafiles[qst_dat], 7)!=0)
712 24 al_trace("Trying to do strncasecmp() when loading a quest\n");
713 24 int32_t qstdat_filename_size = strlen(moduledata.datafiles[qst_dat]);
714 24 al_trace("Filename size of qst.dat file %s is %d.\n", moduledata.datafiles[qst_dat], qstdat_filename_size);
715 //if(strncasecmp(filename, moduledata.datafiles[qst_dat], qstdat_filename_size)!=0)
716
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(strcmp(filename, moduledata.datafiles[qst_dat])!=0)
717 {
718 24 box_out(filename);
719 24 }
720 else
721 {
722 box_out("new quest"); // Or whatever
723 }
724 24 box_out("...");
725 24 box_eol();
726 24 box_eol();
727
728
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(encrypted)
729 {
730 24 box_out("Decrypting...");
731 24 box_save_x();
732 24 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, strstr(filename, ".dat#")!=NULL, passwd);
733
734
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(ret)
735 {
736 switch(ret)
737 {
738 case 1:
739 box_out("error.");
740 box_eol();
741 box_end(true);
742 *open_error=qe_notfound;
743 return NULL;
744
745 case 2:
746 box_out("error.");
747 box_eol();
748 box_end(true);
749 *open_error=qe_internal;
750 return NULL;
751 // be sure not to delete tmpfilename now...
752 }
753
754 if(ret==5) //old encryption?
755 {
756 current_method++;
757 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
758 box_out(percent_done);
759 box_load_x();
760 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
761 }
762
763 if(ret==5) //old encryption?
764 {
765 current_method++;
766 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
767 box_out(percent_done);
768 box_load_x();
769 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
770 }
771
772 if(ret==5) //old encryption?
773 {
774 current_method++;
775 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
776 box_out(percent_done);
777 box_load_x();
778 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
779 }
780
781 if(ret==5) //old encryption?
782 {
783 current_method++;
784 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
785 box_out(percent_done);
786 box_load_x();
787 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
788 }
789
790 if(ret)
791 {
792 oldquest = true;
793 passwd="";
794 }
795 }
796
797 24 box_out("okay.");
798 24 box_eol();
799 24 }
800 else
801 {
802 oldquest = true;
803 }
804
805 24 box_out("Opening...");
806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
807
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!f)
808 {
809 if((compressed==1)&&(errno==EDOM))
810 {
811 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
812 }
813
814 if(!f)
815 {
816 if(!oldquest)
817 {
818 delete_file(tmpfilename);
819 }
820 box_out("error.");
821 box_eol();
822 box_end(true);
823 *open_error=qe_invalid;
824 return NULL;
825 }
826 }
827
828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(!oldquest)
829 {
830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(deletefilename)
831 24 sprintf(deletefilename, "%s", tmpfilename);
832 24 }
833
834 24 box_out("okay.");
835 24 box_eol();
836
837 24 return f;
838 24 }
839
840 11 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
841 {
842 char *filename;
843 11 PACKFILE *f=NULL;
844 11 int32_t open_error=0;
845 11 deletefilename[0]=0;
846
847 11 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
848 11 strcat(qstdat_string,"#NESQST_NEW_QST");
849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(Header->templatepath[0]==0)
850 {
851 11 filename=(char *)malloc(2048);
852 //strcpy(filename, "qst.dat#NESQST_NEW_QST");
853 11 strcpy(filename, qstdat_string);
854 11 }
855 else
856 {
857 filename=Header->templatepath;
858 }
859
860 11 f=open_quest_file(&open_error, filename, deletefilename, true, true,false);
861
862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(Header->templatepath[0]==0)
863 {
864 11 free(filename);
865 11 }
866
867
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!f)
868 {
869 return NULL;
870 }
871
872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(validate)
873 {
874
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!valid_zqt(f))
875 {
876 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,lfont);
877 pack_fclose(f);
878
879 //setPackfilePassword(NULL);
880 if(deletefilename[0])
881 {
882 delete_file(deletefilename);
883 }
884
885 return NULL;
886 }
887 11 }
888
889 11 return f;
890 11 }
891
892 11 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
893 {
894 11 combosread=false;
895 11 mapsread=false;
896 11 fixffcs=false;
897
898
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 switch(section_id)
899 {
900 case ID_RULES:
901 case ID_STRINGS:
902 case ID_MISC:
903 case ID_TILES:
904 case ID_COMBOS:
905 case ID_CSETS:
906 case ID_MAPS:
907 case ID_DMAPS:
908 case ID_DOORS:
909 case ID_ITEMS:
910 case ID_WEAPONS:
911 case ID_COLORS:
912 case ID_ICONS:
913 case ID_INITDATA:
914 case ID_GUYS:
915 case ID_MIDIS:
916 case ID_CHEATS:
917 case ID_ITEMDROPSETS:
918 case ID_FAVORITES:
919 11 break;
920
921 default:
922 return false;
923 break;
924 }
925
926 int32_t ret;
927 word version, build;
928 11 PACKFILE *f=NULL;
929
930 char deletefilename[1024];
931 11 deletefilename[0]=0;
932
933 //why is this here?
934 /*
935 if(colordata==NULL)
936 return false;
937 */
938
939 //setPackfilePassword(datapwd);
940 11 f=open_quest_template(Header, deletefilename, validate);
941
942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!f) //no file, nothing to delete
943 {
944 // setPackfilePassword(NULL);
945 return false;
946 }
947
948 11 ret=get_version_and_build(f, &version, &build);
949
950
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
11 if(ret||(version==0))
951 {
952 pack_fclose(f);
953
954 if(deletefilename[0])
955 {
956 delete_file(deletefilename);
957 }
958
959 // setPackfilePassword(NULL);
960 return false;
961 }
962
963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!find_section(f, section_id))
964 {
965 11 al_trace("Can't find section!\n");
966 11 pack_fclose(f);
967
968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(deletefilename[0])
969 {
970 11 delete_file(deletefilename);
971 11 }
972
973 //setPackfilePassword(NULL);
974 11 return false;
975 }
976
977 switch(section_id)
978 {
979 case ID_RULES:
980 //rules
981 ret=readrules(f, Header, true);
982 break;
983
984 case ID_STRINGS:
985 //strings
986 ret=readstrings(f, Header, true);
987 break;
988
989 case ID_MISC:
990 //misc data
991 ret=readmisc(f, Header, Misc, true);
992 break;
993
994 case ID_TILES:
995 //tiles
996 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true, true);
997 break;
998
999 case ID_COMBOS:
1000 //combos
1001 clear_combos();
1002 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS, true);
1003 combosread=true;
1004 break;
1005
1006 case ID_COMBOALIASES:
1007 //combos
1008 ret=readcomboaliases(f, Header, version, build, true);
1009 break;
1010
1011 case ID_CSETS:
1012 //color data
1013 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL, true);
1014 break;
1015
1016 case ID_MAPS:
1017 //maps
1018 ret=readmaps(f, Header, true);
1019 mapsread=true;
1020 break;
1021
1022 case ID_DMAPS:
1023 //dmaps
1024 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS, true);
1025 break;
1026
1027 case ID_DOORS:
1028 //door combo sets
1029 ret=readdoorcombosets(f, Header, true);
1030 break;
1031
1032 case ID_ITEMS:
1033 //items
1034 ret=readitems(f, version, build, true);
1035 break;
1036
1037 case ID_WEAPONS:
1038 //weapons
1039 ret=readweapons(f, Header, true);
1040 break;
1041
1042 case ID_COLORS:
1043 //misc. colors
1044 ret=readmisccolors(f, Header, Misc, true);
1045 break;
1046
1047 case ID_ICONS:
1048 //game icons
1049 ret=readgameicons(f, Header, Misc, true);
1050 break;
1051
1052 case ID_INITDATA:
1053 //initialization data
1054 ret=readinitdata(f, Header, true);
1055 break;
1056
1057 case ID_GUYS:
1058 //guys
1059 ret=readguys(f, Header, true);
1060 break;
1061
1062 case ID_MIDIS:
1063 //midis
1064 ret=readtunes(f, Header, tunes, true);
1065 break;
1066
1067 case ID_CHEATS:
1068 //cheat codes
1069 ret=readcheatcodes(f, Header, true);
1070 break;
1071
1072 case ID_ITEMDROPSETS:
1073 //item drop sets
1074 // Why is this one commented out?
1075 //ret=readitemdropsets(f, (int32_t)version, (word)build, true);
1076 break;
1077
1078 case ID_FAVORITES:
1079 // favorite combos and aliases
1080 ret=readfavorites(f, version, build, true);
1081 break;
1082
1083 default:
1084 ret=-1;
1085 break;
1086 }
1087
1088 pack_fclose(f);
1089
1090 if(deletefilename[0])
1091 {
1092 delete_file(deletefilename);
1093 }
1094
1095 //setPackfilePassword(NULL);
1096 if(!ret)
1097 {
1098 return true;
1099 }
1100
1101 return false;
1102 11 }
1103
1104 bool init_tiles(bool validate, zquestheader *Header)
1105 {
1106 return init_section(Header, ID_TILES, NULL, NULL, validate);
1107 }
1108
1109 bool init_combos(bool validate, zquestheader *Header)
1110 {
1111 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1112 }
1113
1114 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1115 {
1116 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1117 }
1118
1119 13 void init_spritelists()
1120 {
1121
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(FFCore.quest_format[vZelda] < 0x255)
1122 {
1123 11 guys.setMax(255);
1124 11 items.setMax(255);
1125 11 Ewpns.setMax(255);
1126 11 Lwpns.setMax(255);
1127 11 Sitems.setMax(255);
1128 11 chainlinks.setMax(255);
1129 11 decorations.setMax(255);
1130 11 particles.setMax(255);
1131 11 }
1132 else
1133 {
1134 2 guys.setMax(255);
1135 2 items.setMax(255);
1136 2 Ewpns.setMax(255);
1137 2 Lwpns.setMax(255);
1138 2 Sitems.setMax(255);
1139 2 chainlinks.setMax(255);
1140 2 decorations.setMax(255);
1141 2 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1142 }
1143 13 }
1144
1145 11 bool reset_items(bool validate, zquestheader *Header)
1146 {
1147 11 bool ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1148
1149 //Ignore this, but don't remove it
1150 /*
1151 if (ret)
1152 for(int32_t i=0; i<MAXITEMS; i++)
1153 {
1154 reset_itembuf(&itemsbuf[i], i);
1155 }
1156 */
1157
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1158
1159 11 return ret;
1160 }
1161
1162 bool reset_guys()
1163 {
1164 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1165 init_guys(V_GUYS);
1166 return true;
1167 }
1168
1169 bool reset_wpns(bool validate, zquestheader *Header)
1170 {
1171 bool ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1172
1173 for(int32_t i=0; i<WPNCNT; i++)
1174 reset_weaponname(i);
1175
1176 return ret;
1177 }
1178
1179 bool reset_mapstyles(bool validate, miscQdata *Misc)
1180 {
1181 Misc->colors.blueframe_tile = 20044;
1182 Misc->colors.blueframe_cset = 0;
1183 Misc->colors.triforce_tile = 23461;
1184 Misc->colors.triforce_cset = 1;
1185 Misc->colors.triframe_tile = 18752;
1186 Misc->colors.triframe_cset = 1;
1187 Misc->colors.overworld_map_tile = 16990;
1188 Misc->colors.overworld_map_cset = 2;
1189 Misc->colors.HCpieces_tile = 21160;
1190 Misc->colors.HCpieces_cset = 8;
1191 Misc->colors.dungeon_map_tile = 19651;
1192 Misc->colors.dungeon_map_cset = 8;
1193 return true;
1194 }
1195
1196 bool reset_doorcombosets(bool validate, zquestheader *Header)
1197 {
1198 return init_section(Header, ID_DOORS, NULL, NULL, validate);
1199 }
1200
1201 11 int32_t get_qst_buffers()
1202 {
1203 11 memrequested+=(sizeof(mapscr)*MAPSCRS);
1204 11 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1205 11 TheMaps.resize(MAPSCRS);
1206
1207
2/2
✓ Branch 0 taken 1496 times.
✓ Branch 1 taken 11 times.
1507 for(int32_t i(0); i<MAPSCRS; i++)
1208 1496 TheMaps[i].zero_memory();
1209
1210 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1211 11 Z_message("OK\n"); // Allocating map buffer...
1212
1213 11 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1214 11 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1215
1216
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1217 return 0;
1218
1219 11 Z_message("OK\n");
1220
1221 // Allocating space for all 65535 strings uses up 10.62MB...
1222 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1223 // (Shoelace's "Hero of Dreams" uses 1415.)
1224 // So let's be a bit generous and allow 4096 initially.
1225 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1226 // I tested it and it worked without flaw on 6/6/11. - L.
1227 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1228 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1229 // See https://discord.com/channels/876899628556091432/992984989073416242
1230 11 msg_strings_size = 8192;
1231 11 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1232 11 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1233
1234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 MsgStrings = new MsgStr[msg_strings_size];
1235
1236 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1237
2/2
✓ Branch 0 taken 90112 times.
✓ Branch 1 taken 11 times.
90123 for(auto q = 0; q < msg_strings_size; ++q)
1238 {
1239 90112 MsgStrings[q].clear();
1240 90112 }
1241 11 Z_message("OK\n"); // Allocating string buffer...
1242
1243 11 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1244 11 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1245
1246
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1247 return 0;
1248
1249 11 Z_message("OK\n"); // Allocating door combo buffer...
1250
1251 11 memrequested+=(sizeof(dmap)*MAXDMAPS);
1252 11 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1253
1254
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1255 return 0;
1256
1257 11 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1258 11 Z_message("OK\n"); // Allocating dmap buffer...
1259
1260 11 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1261 11 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1262
1263
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((combobuf=(newcombo*)malloc(sizeof(newcombo)*MAXCOMBOS))==NULL)
1264 return 0;
1265
1266 11 memset(combobuf, 0, sizeof(newcombo)*MAXCOMBOS);
1267 11 Z_message("OK\n"); // Allocating combo buffer...
1268
1269 11 memrequested+=(psTOTAL255);
1270 11 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1271
1272
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1273 return 0;
1274
1275 11 Z_message("OK\n"); // Allocating color data buffer...
1276
1277 11 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1278 11 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1279
1280 11 free_newtilebuf();
1281
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1282 return 0;
1283
1284 11 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1285 //Z_message("Performed memset on tiles\n");
1286 11 clear_tiles(newtilebuf);
1287 //Z_message("Performed clear_tiles()\n");
1288 11 Z_message("OK\n"); // Allocating tile buffer...
1289
1290
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(is_zquest())
1291 {
1292 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1293 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1294
1295 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1296 return 0;
1297
1298 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1299 clear_tiles(grabtilebuf);
1300 Z_message("OK\n"); // Allocating tile grab buffer...
1301 }
1302
1303 11 memrequested+=(100000);
1304 11 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1305
1306
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((trashbuf=(byte*)malloc(100000))==NULL)
1307 return 0;
1308
1309 11 Z_message("OK\n"); // Allocating trash buffer...
1310
1311 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1312 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1313 // fixed by ensuring there's actually itemdata there.
1314 // If you change this, be sure to update del_qst_buffers, too.
1315
1316 11 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1317 11 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1318
1319
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1320 return 0;
1321
1322 11 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1323 11 itemsbuf++;
1324 11 Z_message("OK\n"); // Allocating item buffer...
1325
1326 11 memrequested+=(sizeof(wpndata)*MAXWPNS);
1327 11 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1328
1329
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1330 return 0;
1331
1332 11 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1333 11 Z_message("OK\n"); // Allocating weapon buffer...
1334
1335 11 memrequested+=(sizeof(guydata)*MAXGUYS);
1336 11 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1337
1338
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1339 return 0;
1340
1341 11 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1342 11 Z_message("OK\n"); // Allocating guy buffer...
1343
1344 11 memrequested+=(sizeof(comboclass)*cMAX);
1345 11 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1346
1347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1348 return 0;
1349
1350 11 Z_message("OK\n"); // Allocating combo class buffer...
1351
1352 11 return 1;
1353 11 }
1354
1355
1356 11 void free_newtilebuf()
1357 {
1358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(newtilebuf)
1359 {
1360 for(int32_t i=0; i<NEWMAXTILES; i++)
1361 if(newtilebuf[i].data)
1362 free(newtilebuf[i].data);
1363
1364 free(newtilebuf);
1365 newtilebuf = 0;
1366 }
1367 11 }
1368
1369 void free_grabtilebuf()
1370 {
1371 if(is_zquest())
1372 {
1373 if(grabtilebuf)
1374 {
1375 for(int32_t i=0; i<NEWMAXTILES; i++)
1376 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1377
1378 free(grabtilebuf);
1379 grabtilebuf = 0;
1380 }
1381 }
1382 }
1383
1384 void del_qst_buffers()
1385 {
1386 al_trace("Cleaning maps. \n");
1387
1388 if(ZCMaps) free(ZCMaps);
1389
1390 if(MsgStrings) delete[] MsgStrings;
1391
1392 if(DoorComboSets) free(DoorComboSets);
1393
1394 if(DMaps) free(DMaps);
1395
1396 if(combobuf) free(combobuf);
1397
1398 if(colordata) free(colordata);
1399
1400 al_trace("Cleaning tile buffers. \n");
1401 free_newtilebuf();
1402 free_grabtilebuf();
1403
1404 al_trace("Cleaning misc. \n");
1405
1406 if(trashbuf) free(trashbuf);
1407
1408 // See get_qst_buffers
1409 if(itemsbuf)
1410 {
1411 itemsbuf--;
1412 free(itemsbuf);
1413 }
1414
1415 if(wpnsbuf) free(wpnsbuf);
1416
1417 if(guysbuf) free(guysbuf);
1418
1419 if(combo_class_buf) free(combo_class_buf);
1420 }
1421
1422 bool init_palnames()
1423 {
1424 // if(palnames==NULL)
1425 // return false;
1426
1427 for(int32_t x=0; x<MAXLEVELS; x++)
1428 {
1429 switch(x)
1430 {
1431 case 0:
1432 sprintf(palnames[x],"Overworld");
1433 break;
1434
1435 case 10:
1436 sprintf(palnames[x],"Caves");
1437 break;
1438
1439 case 11:
1440 sprintf(palnames[x],"Passageways");
1441 break;
1442
1443 default:
1444 sprintf(palnames[x],"%c",0);
1445 break;
1446 }
1447 }
1448
1449 return true;
1450 }
1451
1452 1042 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size, bool keepdata)
1453 {
1454 void *p;
1455
1456
1/2
✓ Branch 0 taken 1042 times.
✗ Branch 1 not taken.
1042 p = _AL_MALLOC(MAX(size, alloc_size));
1457
1458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1042 times.
1042 if(!p)
1459 {
1460 return NULL;
1461 }
1462
1463
1/2
✓ Branch 0 taken 1042 times.
✗ Branch 1 not taken.
1042 if(!pfread(p,size,f,keepdata))
1464 {
1465 _AL_FREE(p);
1466 return NULL;
1467 }
1468
1469
1/2
✓ Branch 0 taken 1042 times.
✗ Branch 1 not taken.
1042 if(pack_ferror(f))
1470 {
1471 _AL_FREE(p);
1472 return NULL;
1473 }
1474
1475 1042 return p;
1476 1042 }
1477
1478 /* read_midi:
1479 * Reads MIDI data from a datafile (this is not the same thing as the
1480 * standard midi file format).
1481 */
1482
1483 90 static MIDI *read_midi(PACKFILE *f, bool)
1484 {
1485 MIDI *m;
1486 int32_t c;
1487 90 int16_t divisions=0;
1488 90 int32_t len=0;
1489
1490 90 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1491
1492
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!m)
1493 {
1494 return NULL;
1495 }
1496
1497
2/2
✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 90 times.
2970 for(c=0; c<MIDI_TRACKS; c++)
1498 {
1499 2880 m->track[c].len = 0;
1500 2880 m->track[c].data = NULL;
1501 2880 }
1502
1503 90 p_mgetw(&divisions,f,true);
1504 90 m->divisions=divisions;
1505
1506
2/2
✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 90 times.
2970 for(c=0; c<MIDI_TRACKS; c++)
1507 {
1508 2880 p_mgetl(&len,f,true);
1509 2880 m->track[c].len=len;
1510
1511
2/2
✓ Branch 0 taken 1838 times.
✓ Branch 1 taken 1042 times.
2880 if(m->track[c].len > 0)
1512 {
1513 1042 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0, true);
1514
1515
1/2
✓ Branch 0 taken 1042 times.
✗ Branch 1 not taken.
1042 if(!m->track[c].data)
1516 {
1517 destroy_midi(m);
1518 return NULL;
1519 }
1520 1042 }
1521 2880 }
1522
1523 LOCK_DATA(m, sizeof(MIDI));
1524
1525
2/2
✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 90 times.
2970 for(c=0; c<MIDI_TRACKS; c++)
1526 {
1527
2/2
✓ Branch 0 taken 1042 times.
✓ Branch 1 taken 1838 times.
2880 if(m->track[c].data)
1528 {
1529 LOCK_DATA(m->track[c].data, m->track[c].len);
1530 1042 }
1531 2880 }
1532
1533 90 return m;
1534 90 }
1535
1536 void clear_combo(int32_t i)
1537 {
1538 combobuf[i].clear();
1539 }
1540
1541 void clear_combos()
1542 {
1543 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1544 clear_combo(tmpcounter);
1545 }
1546
1547 void pack_combos()
1548 {
1549 int32_t di = 0;
1550
1551 for(int32_t si=0; si<1024; si+=2)
1552 combobuf[di++] = combobuf[si];
1553
1554 for(; di<1024; di++)
1555 clear_combo(di);
1556 }
1557
1558 13 void reset_tunes(zctune *tune)
1559 {
1560
2/2
✓ Branch 0 taken 3276 times.
✓ Branch 1 taken 13 times.
3289 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1561 {
1562 3276 tune[i].reset();
1563 3276 }
1564 13 }
1565
1566
1567 /*void reset_midi(zcmidi_ *m)
1568 {
1569 m->title[0]=0;
1570 m->loop=1;
1571 m->volume=144;
1572 m->start=0;
1573 m->loop_start=-1;
1574 m->loop_end=-1;
1575 if(m->midi)
1576 {
1577 destroy_midi(m->midi);
1578 }
1579 m->midi=NULL;
1580 }
1581
1582
1583 void reset_midis(zcmidi_ *m)
1584 {
1585 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1586 {
1587 reset_midi(m+i);
1588 }
1589 }
1590 */
1591
1592 void reset_scr(int32_t scr)
1593 {
1594 /*
1595 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1596 for(unsigned i=0; i<sizeof(mapscr); i++)
1597 *(di++) = 0;
1598 TheMaps[scr].valid=mVERSION;
1599 */
1600
1601 TheMaps[scr].zero_memory();
1602 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1603
1604 for(int32_t i=0; i<6; i++)
1605 {
1606 //these will be uncommented later
1607 //TheMaps[scr].layerxsize[i]=16;
1608 //TheMaps[scr].layerysize[i]=11;
1609 TheMaps[scr].layeropacity[i]=255;
1610 }
1611
1612 TheMaps[scr].valid=mVERSION;
1613
1614 }
1615
1616 /* For reference:
1617
1618 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1619 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1620 */
1621
1622 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1623 {
1624 for(int32_t i=0; i<9; i++)
1625 {
1626 for(int32_t j=0; j<6; j++)
1627 {
1628 if(j<4)
1629 {
1630 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1631 {
1632 return false;
1633 }
1634
1635 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1636 {
1637 return false;
1638 }
1639
1640 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1641 {
1642 return false;
1643 }
1644
1645 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1646 {
1647 return false;
1648 }
1649 }
1650
1651 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1652 {
1653 return false;
1654 }
1655
1656 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1657 {
1658 return false;
1659 }
1660
1661 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1662 {
1663 return false;
1664 }
1665
1666 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1667 {
1668 return false;
1669 }
1670 }
1671
1672 if(i<2)
1673 {
1674 if(a.flags[i]!=b.flags[i])
1675 {
1676 return false;
1677 }
1678
1679 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1680 {
1681 return false;
1682 }
1683
1684 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1685 {
1686 return false;
1687 }
1688
1689 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1690 {
1691 return false;
1692 }
1693
1694 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1695 {
1696 return false;
1697 }
1698 }
1699
1700 if(i<3)
1701 {
1702 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1703 {
1704 return false;
1705 }
1706
1707 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1708 {
1709 return false;
1710 }
1711
1712 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1713 {
1714 return false;
1715 }
1716
1717 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1718 {
1719 return false;
1720 }
1721 }
1722
1723 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1724 {
1725 return false;
1726 }
1727
1728 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1729 {
1730 return false;
1731 }
1732 }
1733
1734 return true;
1735 }
1736
1737 int32_t doortranslations_u[9][4]=
1738 {
1739 {37,38,53,54},
1740 {37,38,39,40},
1741 {37,38,55,56},
1742 {37,38,39,40},
1743 {37,38,53,54},
1744 {37,38,53,54},
1745 {37,38,53,54},
1746 {7,8,23,24},
1747 {7,8,41,42}
1748 };
1749
1750 int32_t doortranslations_d[9][4]=
1751 {
1752 {117,118,133,134},
1753 {135,136,133,134},
1754 {119,120,133,134},
1755 {135,136,133,134},
1756 {117,118,133,134},
1757 {117,118,133,134},
1758 {117,118,133,134},
1759 {151,152,167,168},
1760 {137,138,167,168},
1761 };
1762
1763 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1764 int32_t doortranslations_l[9][6]=
1765 {
1766 {66,67,82,83,98,99},
1767 {66,68,82,84,98,100},
1768 {66,69,82,85,98,101},
1769 {66,68,82,84,98,100},
1770 {66,67,82,83,98,99},
1771 {66,67,82,83,98,99},
1772 {66,67,82,83,98,99},
1773 {64,65,80,81,96,97},
1774 {64,65,80,114,96,97},
1775 };
1776
1777 int32_t doortranslations_r[9][6]=
1778 {
1779
1780 {76,77,92,93,108,109},
1781 {75,77,91,93,107,109},
1782 {74,77,90,93,106,109},
1783 {75,77,91,93,107,109},
1784 {76,77,92,93,108,109},
1785 {76,77,92,93,108,109},
1786 {76,77,92,93,108,109},
1787 {78,79,94,95,110,111},
1788 {78,79,125,95,110,111},
1789 };
1790
1791 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1792 {
1793 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1794 }
1795
1796 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1797 {
1798 //these are here to bypass compiler warnings about unused arguments
1799 map=map;
1800 scr=scr;
1801 pos=pos;
1802
1803 //what does this function do?
1804 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1805 return 2;
1806 }
1807
1808 int32_t MakeDoors(int32_t map, int32_t scr)
1809 {
1810 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1811 {
1812 return 0;
1813 }
1814
1815 DoorComboSet tempdcs;
1816 memset(&tempdcs, 0, sizeof(DoorComboSet));
1817
1818 //up
1819 for(int32_t i=0; i<9; i++)
1820 {
1821 for(int32_t j=0; j<4; j++)
1822 {
1823 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1824 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1825 }
1826 }
1827
1828 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1829 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1830 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1831 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1832 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1833 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1834
1835 //down
1836 for(int32_t i=0; i<9; i++)
1837 {
1838 for(int32_t j=0; j<4; j++)
1839 {
1840 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1841 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1842 }
1843 }
1844
1845 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1846
1847 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1848 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1849 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1850 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1851 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1852
1853 //left
1854 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1855 for(int32_t i=0; i<9; i++)
1856 {
1857 for(int32_t j=0; j<6; j++)
1858 {
1859 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1860 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1861 }
1862 }
1863
1864 for(int32_t j=0; j>6; j++)
1865 {
1866 if((j!=2)&&(j!=3))
1867 {
1868 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1869 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1870 }
1871 }
1872
1873 tempdcs.bombdoorcombo_l[0]=0;
1874 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1875 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1876 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1877 tempdcs.bombdoorcombo_l[2]=0;
1878 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1879 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1880 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1881
1882 //right
1883 for(int32_t i=0; i<9; i++)
1884 {
1885 for(int32_t j=0; j<6; j++)
1886 {
1887 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1888 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1889 }
1890 }
1891
1892 for(int32_t j=0; j>6; j++)
1893 {
1894 if((j!=2)&&(j!=3))
1895 {
1896 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1897 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1898 }
1899 }
1900
1901 tempdcs.bombdoorcombo_r[0]=0;
1902 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1903 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1904 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1905 tempdcs.bombdoorcombo_r[2]=0;
1906 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1907 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1908 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1909
1910 int32_t k;
1911
1912 for(k=0; k<door_combo_set_count; k++)
1913 {
1914 if(DoorComboSets[k]==tempdcs)
1915 {
1916 break;
1917 }
1918 }
1919
1920 if(k==door_combo_set_count)
1921 {
1922 DoorComboSets[k]=tempdcs;
1923 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1924 ++door_combo_set_count;
1925 }
1926
1927 return k;
1928 /*
1929 doorcombo_u[9][4];
1930 doorcset_u[9][4];
1931 doorcombo_d[9][4];
1932 doorcset_d[9][4];
1933 doorcombo_l[9][6];
1934 doorcset_l[9][6];
1935 doorcombo_r[9][6];
1936 doorcset_r[9][6];
1937 bombdoorcombo_u[2];
1938 bombdoorcset_u[2];
1939 bombdoorcombo_d[2];
1940 bombdoorcset_d[2];
1941 bombdoorcombo_l[3];
1942 bombdoorcset_l[3];
1943 bombdoorcombo_r[3];
1944 bombdoorcset_r[3];
1945 walkthroughcombo[4];
1946 walkthroughcset[4];
1947 */
1948 }
1949
1950 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1951 {
1952 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1953 }
1954
1955 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1956 {
1957
1958 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1959 }
1960
1961 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1962 {
1963 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1964 }
1965
1966
1967 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1968 {
1969 char temp_pwd[30];
1970 memset(temp_pwd,0,30);
1971
1972 if(pwdkey!=0)
1973 {
1974 memcpy(temp_pwd,encrypted_pwd,30);
1975 temp_pwd[29]=0;
1976
1977 for(int32_t i=0; i<30; i++)
1978 {
1979 temp_pwd[i] -= pwdkey;
1980 int32_t t=pwdkey>>15;
1981 pwdkey = (pwdkey<<1)+t;
1982 }
1983 }
1984
1985 memcpy(pwd,temp_pwd,30);
1986 }
1987
1988
1989
1990 bool check_questpwd(zquestheader *Header, char *pwd)
1991 {
1992 #if DEVLEVEL > 3
1993 return true;
1994 #endif
1995
1996 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
1997 cvs_MD5Context ctx;
1998 uint8_t md5sum[16];
1999
2000 cvs_MD5Init(&ctx);
2001 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2002 cvs_MD5Final(md5sum, &ctx);
2003
2004 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2005
2006 }
2007
2008 13 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2009 {
2010 13 zprint2("\n");
2011 13 zprint2("[ZQUEST CREATOR METADATA]\n");
2012
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(qst_num < moduledata.max_quest_files)
2013 zprint2("Loading module quest %d\n", qst_num+1);
2014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(path) zprint2("Loading '%s'\n", path);
2015
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if ( tempheader.new_version_id_main > 0 )
2016 {
2017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(tempheader.new_version_id_fourth > 0)
2018 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2019 tempheader.new_version_id_main,tempheader.new_version_id_second,
2020 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2021 13 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2022 13 tempheader.new_version_id_main,tempheader.new_version_id_second,
2023 13 tempheader.new_version_id_third);
2024 13 }
2025 else
2026 {
2027 switch ( tempheader.zelda_version )
2028 {
2029 case 0x255:
2030 {
2031 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2032 break;
2033 }
2034 case 0x254:
2035 {
2036 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2037 break;
2038 }
2039 case 0x250:
2040 {
2041 switch(tempheader.build)
2042 {
2043 case 19:
2044 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2045 case 20:
2046 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2047 case 21:
2048 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2049 case 22:
2050 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2051 case 23:
2052 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2053 case 24:
2054 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2055 case 25:
2056 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2057 case 26:
2058 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2059 case 27:
2060 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2061 case 28:
2062 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2063 case 29:
2064 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2065 case 30:
2066 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2067 case 31:
2068 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2069 case 32:
2070 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2071 case 33:
2072 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2073 default:
2074 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2075
2076 }
2077 break;
2078 }
2079
2080 case 0x211:
2081 {
2082 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2083 }
2084 case 0x210:
2085 {
2086 zprint2("Last saved in ZQuest Version: 2.10.x");
2087 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2088 break;
2089 }
2090 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2091 case 0x193:
2092 {
2093 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2094 }
2095 case 0x192:
2096 {
2097 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2098 }
2099 case 0x190:
2100 {
2101 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2102 }
2103 case 0x184:
2104 {
2105 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2106 }
2107 case 0x183:
2108 {
2109 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2110 }
2111 case 0x180:
2112 {
2113 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2114 }
2115 default:
2116 {
2117 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2118 }
2119 */
2120 }
2121 }
2122
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
13 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2123 2 zprint2("%s\n", tempheader.getAlphaVerStr());
2124 11 else zprint2("\n");
2125
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2126
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2127
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2128
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2130
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2131 13 zprint2("\n");
2132 13 }
2133
2134 24 int32_t readheader(PACKFILE *f, zquestheader *Header, bool keepdata, byte printmetadata)
2135 {
2136 int32_t dummy;
2137 zquestheader tempheader;
2138 24 memcpy(&tempheader, Header, sizeof(tempheader));
2139 char dummybuf[80];
2140 byte temp_map_count;
2141 byte temp_midi_flags[MIDIFLAGS_SIZE];
2142 word version;
2143 char temp_pwd[30], temp_pwd2[30];
2144 int16_t temp_pwdkey;
2145 cvs_MD5Context ctx;
2146 24 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2147 24 memset(&tempheader, 0, sizeof(tempheader));
2148 24 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2149
2150
2151
2152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f,true)) // first read old header
2153 {
2154 Z_message("Unable to read header string\n");
2155 return qe_invalid;
2156 }
2157
2158 // check header
2159
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2160 {
2161 if(strcmp(tempheader.id_str,QH_IDSTR))
2162 {
2163 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2164 return qe_invalid;
2165 }
2166 }
2167
2168 24 int32_t templatepath_len=0;
2169
2170 24 tempheader.external_zinfo = false;
2171 24 read_zinfo = false;
2172
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2173 {
2174 byte padding;
2175
2176 if(!p_getc(&padding,f,true))
2177 {
2178 return qe_invalid;
2179 }
2180
2181 if(!p_igetw(&tempheader.zelda_version,f,true))
2182 {
2183 return qe_invalid;
2184 }
2185
2186 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2187
2188 if(tempheader.zelda_version > ZELDA_VERSION)
2189 {
2190 return qe_version;
2191 }
2192
2193 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2194
2195 if(strcmp(tempheader.id_str,QH_IDSTR))
2196 {
2197 return qe_invalid;
2198 }
2199
2200 if(bad_version(tempheader.zelda_version))
2201 {
2202 return qe_obsolete;
2203 }
2204
2205 if(!p_igetw(&tempheader.internal,f,true))
2206 {
2207 return qe_invalid;
2208 }
2209
2210 if(!p_getc(&tempheader.quest_number,f,true))
2211 {
2212 return qe_invalid;
2213 }
2214
2215 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2216
2217 if(!pfread(&quest_rules[0],2,f,true))
2218 {
2219 return qe_invalid;
2220 }
2221
2222 if(!p_getc(&temp_map_count,f,true))
2223 {
2224 return qe_invalid;
2225 }
2226
2227 FFCore.quest_format[qMapCount] = temp_map_count;
2228
2229 if(!p_getc(&tempheader.old_str_count,f,true))
2230 {
2231 return qe_invalid;
2232 }
2233
2234 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2235 {
2236 return qe_invalid;
2237 }
2238
2239 if(!pfread(temp_midi_flags,4,f,true))
2240 {
2241 return qe_invalid;
2242 }
2243
2244 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2245 {
2246 return qe_invalid;
2247 }
2248
2249 if(!pfread(dummybuf,14,f,true))
2250 {
2251 return qe_invalid;
2252 }
2253
2254 if(!pfread(&quest_rules[2],2,f,true))
2255 {
2256 return qe_invalid;
2257 }
2258
2259 if(!p_getc(&dummybuf,f,true))
2260 {
2261 return qe_invalid;
2262 }
2263
2264 if(!pfread(tempheader.version,sizeof(tempheader.version),f,true))
2265 {
2266 return qe_invalid;
2267 }
2268
2269 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2270 {
2271 return qe_invalid;
2272 }
2273
2274 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2275 {
2276 return qe_invalid;
2277 }
2278
2279 if(!p_getc(&padding,f,true))
2280 {
2281 return qe_invalid;
2282 }
2283
2284 if(!p_igetw(&temp_pwdkey,f,true))
2285 {
2286 return qe_invalid;
2287 }
2288
2289 if(!pfread(temp_pwd,30,f,true))
2290 {
2291 return qe_invalid;
2292 }
2293
2294 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2295 cvs_MD5Init(&ctx);
2296 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2297 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2298
2299 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2300 {
2301 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2302 // Not anymore...
2303 memset(tempheader.minver,0,9);
2304 tempheader.build=0;
2305 tempheader.use_keyfile=0;
2306 memset(tempheader.old_foo, 0, 9);
2307 }
2308 else
2309 {
2310 if(!pfread(tempheader.minver,sizeof(tempheader.minver),f,true))
2311 {
2312 return qe_invalid;
2313 }
2314
2315 if(!p_getc(&tempheader.build,f,true))
2316 {
2317 return qe_invalid;
2318 }
2319
2320 FFCore.quest_format[vBuild] = tempheader.build;
2321
2322 if(!p_getc(&tempheader.use_keyfile,f,true))
2323 {
2324 return qe_invalid;
2325 }
2326
2327 if(!pfread(dummybuf,9,f,true))
2328 {
2329 return qe_invalid;
2330 }
2331 } // starting at minver
2332
2333 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2334 {
2335 memset(&quest_rules[4],0,16); // word rules3..rules10
2336 }
2337 else
2338 {
2339 if(!pfread(&quest_rules[4],16,f,true)) // read new header additions
2340 {
2341 return qe_invalid; // starting at rules3
2342 }
2343
2344 if(tempheader.zelda_version <= 0x190)
2345 {
2346 set_bit(quest_rules,qr_MEANPLACEDTRAPS,0);
2347 }
2348 }
2349
2350 if((tempheader.zelda_version < 0x192)||
2351 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2352 {
2353 set_bit(quest_rules,qr_BRKNSHLDTILES,(get_bit(quest_rules,qr_BRKBLSHLDS_DEP)));
2354 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2355 }
2356
2357 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2358 {
2359 byte *mf=temp_midi_flags;
2360
2361 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2362 {
2363 mf=(byte*)dummybuf;
2364 }
2365
2366 if(!pfread(mf,32,f,true)) // read new header additions
2367 {
2368 return qe_invalid; // starting at foo2
2369 }
2370
2371 if(!pfread(dummybuf,18,f,true)) // read new header additions
2372 {
2373 return qe_invalid; // starting at foo2
2374 }
2375 }
2376
2377 if((tempheader.zelda_version < 0x192)||
2378 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2379 {
2380 memset(tempheader.templatepath,0,2048);
2381 }
2382 else
2383 {
2384 if(!pfread(tempheader.templatepath,280,f,true)) // read templatepath
2385 {
2386 return qe_invalid;
2387 }
2388 }
2389
2390 if((tempheader.zelda_version < 0x192)||
2391 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2392 {
2393 tempheader.use_keyfile=0;
2394 }
2395 }
2396 else
2397 {
2398 //section id
2399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(!p_mgetl(&dummy,f,true))
2400 {
2401 return qe_invalid;
2402 }
2403
2404 //section version info
2405
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&version,f,true))
2406 {
2407 return qe_invalid;
2408 }
2409
2410 24 FFCore.quest_format[vHeader] = version;
2411
2412
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&dummy,f,true))
2413 {
2414 return qe_invalid;
2415 }
2416
2417 //section size
2418
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetl(&dummy,f,true))
2419 {
2420 return qe_invalid;
2421 }
2422
2423 //finally... section data
2424
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f,true))
2425 {
2426 return qe_invalid;
2427 }
2428
2429 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2430
2431 //do some quick checking...
2432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
2433 {
2434 return qe_version;
2435 }
2436
2437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2438 {
2439 return qe_invalid;
2440 }
2441
2442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(bad_version(tempheader.zelda_version))
2443 {
2444 return qe_obsolete;
2445 }
2446
2447
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.build,f,true))
2448 {
2449 return qe_invalid;
2450 }
2451
2452 24 FFCore.quest_format[vBuild] = tempheader.build;
2453
2454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(version<3)
2455 {
2456 if(!pfread(temp_pwd,30,f,true))
2457 {
2458 return qe_invalid;
2459 }
2460
2461 if(!p_igetw(&temp_pwdkey,f,true))
2462 {
2463 return qe_invalid;
2464 }
2465
2466 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2467 cvs_MD5Init(&ctx);
2468 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2469 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2470 }
2471 else
2472 {
2473
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f,true))
2474 {
2475 return qe_invalid;
2476 }
2477 }
2478
2479
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&tempheader.internal,f,true))
2480 {
2481 return qe_invalid;
2482 }
2483
2484
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.quest_number,f,true))
2485 {
2486 return qe_invalid;
2487 }
2488
2489 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2490
2491
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.version,sizeof(tempheader.version),f,true))
2492 {
2493 return qe_invalid;
2494 }
2495
2496 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2497 //needs to be copied as char[9] or stored as a s.str
2498
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.minver,sizeof(tempheader.minver),f,true))
2499 {
2500 return qe_invalid;
2501 }
2502
2503 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2504 //needs to be copied as char[9] or stored as a s.str
2505
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2506 {
2507 return qe_invalid;
2508 }
2509
2510
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2511 {
2512 return qe_invalid;
2513 }
2514
2515
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f,true))
2516 {
2517 return qe_invalid;
2518 }
2519
2520 /*
2521 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f,true))
2522 {
2523 return qe_invalid;
2524 }
2525 */
2526
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2527 {
2528 return qe_invalid;
2529 }
2530
2531
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(&dummybuf,4,f,true))
2532 {
2533 return qe_invalid;
2534 }
2535
2536
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2537 {
2538 return qe_invalid;
2539 }
2540
2541
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(dummybuf,14,f,true))
2542 {
2543 return qe_invalid;
2544 }
2545
2546 24 templatepath_len=sizeof(tempheader.templatepath);
2547
2548
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(version==1)
2549 {
2550 templatepath_len=280;
2551 }
2552
2553
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.templatepath,templatepath_len,f,true))
2554 {
2555 return qe_invalid;
2556 }
2557
2558
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&temp_map_count,f,true))
2559 {
2560 return qe_invalid;
2561 }
2562
2563
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 11 times.
24 if(version>=4)
2564 {
2565
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&tempheader.new_version_id_main,f,true))
2566 {
2567 return qe_invalid;
2568 }
2569
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&tempheader.new_version_id_second,f,true))
2570 {
2571 return qe_invalid;
2572 }
2573
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&tempheader.new_version_id_third,f,true))
2574 {
2575 return qe_invalid;
2576 }
2577
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&tempheader.new_version_id_fourth,f,true))
2578 {
2579 return qe_invalid;
2580 }
2581
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&tempheader.new_version_id_alpha,f,true))
2582 {
2583 return qe_invalid;
2584 }
2585
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&tempheader.new_version_id_beta,f,true))
2586 {
2587 return qe_invalid;
2588 }
2589
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&tempheader.new_version_id_gamma,f,true))
2590 {
2591 return qe_invalid;
2592 }
2593
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&tempheader.new_version_id_release,f,true))
2594 {
2595 return qe_invalid;
2596 }
2597
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&tempheader.new_version_id_date_year,f,true))
2598 {
2599 return qe_invalid;
2600 }
2601
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&tempheader.new_version_id_date_month,f,true))
2602 {
2603 return qe_invalid;
2604 }
2605
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&tempheader.new_version_id_date_day,f,true))
2606 {
2607 return qe_invalid;
2608 }
2609
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&tempheader.new_version_id_date_hour,f,true))
2610 {
2611 return qe_invalid;
2612 }
2613
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&tempheader.new_version_id_date_minute,f,true))
2614 {
2615 return qe_invalid;
2616 }
2617
2618
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!pfread(tempheader.new_version_devsig,256,f,true))
2619 {
2620 return qe_invalid;
2621 }
2622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2623 strcpy(tempheader.new_version_devsig, "EmilyV99");
2624
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!pfread(tempheader.new_version_compilername,256,f,true))
2625 {
2626 return qe_invalid;
2627 }
2628
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!pfread(tempheader.new_version_compilerversion,256,f,true))
2629 {
2630 return qe_invalid;
2631 }
2632
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!pfread(tempheader.product_name,1024,f,true))
2633 {
2634 return qe_invalid;
2635 }
2636
2637
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&tempheader.compilerid,f,true))
2638 {
2639 return qe_invalid;
2640 }
2641
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&tempheader.compilerversionnumber_first,f,true))
2642 {
2643 return qe_invalid;
2644 }
2645
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&tempheader.compilerversionnumber_second,f,true))
2646 {
2647 return qe_invalid;
2648 }
2649
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&tempheader.compilerversionnumber_third,f,true))
2650 {
2651 return qe_invalid;
2652 }
2653
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f,true))
2654 {
2655 return qe_invalid;
2656 }
2657
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&tempheader.developerid,f,true))
2658 {
2659 return qe_invalid;
2660 }
2661
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!pfread(tempheader.made_in_module_name,1024,f,true))
2662 {
2663 return qe_invalid;
2664 }
2665
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!pfread(tempheader.build_datestamp,256,f,true))
2666 {
2667 return qe_invalid;
2668 }
2669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!pfread(tempheader.build_timestamp,256,f,true))
2670 {
2671 return qe_invalid;
2672 }
2673 13 }
2674 else // <4
2675 {
2676 11 tempheader.new_version_id_main = 0;
2677 11 tempheader.new_version_id_second = 0;
2678 11 tempheader.new_version_id_third = 0;
2679 11 tempheader.new_version_id_fourth = 0;
2680 11 tempheader.new_version_id_alpha = 0;
2681 11 tempheader.new_version_id_beta = 0;
2682 11 tempheader.new_version_id_gamma = 0;
2683 11 tempheader.new_version_id_release = 0;
2684 11 tempheader.new_version_id_date_year = 0;
2685 11 tempheader.new_version_id_date_month = 0;
2686 11 tempheader.new_version_id_date_day = 0;
2687 11 tempheader.new_version_id_date_hour = 0;
2688 11 tempheader.new_version_id_date_minute = 0;
2689
2690 11 memset(tempheader.new_version_devsig, 0, 256);
2691 11 memset(tempheader.new_version_compilername, 0, 256);
2692 11 memset(tempheader.new_version_compilerversion, 0, 256);
2693 11 memset(tempheader.product_name, 0, 1024);
2694 11 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2695
2696 11 tempheader.compilerid = 0;
2697 11 tempheader.compilerversionnumber_first = 0;
2698 11 tempheader.compilerversionnumber_second = 0;
2699 11 tempheader.compilerversionnumber_third = 0;
2700 11 tempheader.compilerversionnumber_fourth = 0;
2701 11 tempheader.developerid = 0;
2702
2703 11 memset(tempheader.made_in_module_name, 0, 1024);
2704 11 memset(tempheader.build_datestamp, 0, 256);
2705 11 memset(tempheader.build_timestamp, 0, 256);
2706 }
2707
2708
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 11 times.
24 if ( version >= 5 )
2709 {
2710
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!pfread(tempheader.build_timezone,6,f,true))
2711 {
2712 return qe_invalid;
2713 }
2714 13 }
2715 else // < 5
2716 {
2717 11 memset(tempheader.build_timezone, 0, 6);
2718 }
2719
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 13 times.
24 if ( version >= 6 )
2720 {
2721 byte b;
2722
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&b,f,true))
2723 {
2724 return qe_invalid;
2725 }
2726 13 tempheader.external_zinfo = b?true:false;
2727 13 read_zinfo = true;
2728 13 }
2729
2730
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 11 times.
24 if(version >= 7)
2731 {
2732
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&(tempheader.new_version_is_nightly),f,true))
2733 {
2734 return qe_invalid;
2735 }
2736 13 }
2737 else
2738 {
2739 11 tempheader.new_version_is_nightly = false;
2740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(tempheader.zelda_version < 0x255)
2741 {
2742
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
11 switch(tempheader.zelda_version)
2743 {
2744 case 0x254:
2745 tempheader.new_version_id_main = 2;
2746 tempheader.new_version_id_second = 54;
2747 break;
2748 case 0x250:
2749
5/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✓ Branch 14 taken 7 times.
✗ Branch 15 not taken.
11 switch(tempheader.build)
2750 {
2751 case 19:
2752 tempheader.new_version_id_main = 2;
2753 tempheader.new_version_id_second = 50;
2754 tempheader.new_version_id_gamma = 1;
2755 break;
2756 case 20:
2757 tempheader.new_version_id_main = 2;
2758 tempheader.new_version_id_second = 50;
2759 tempheader.new_version_id_gamma = 2;
2760 break;
2761 case 21:
2762 tempheader.new_version_id_main = 2;
2763 tempheader.new_version_id_second = 50;
2764 tempheader.new_version_id_gamma = 3;
2765 break;
2766 case 22:
2767 tempheader.new_version_id_main = 2;
2768 tempheader.new_version_id_second = 50;
2769 tempheader.new_version_id_gamma = 4;
2770 break;
2771 case 23:
2772 tempheader.new_version_id_main = 2;
2773 tempheader.new_version_id_second = 50;
2774 tempheader.new_version_id_gamma = 5;
2775 break;
2776 case 24:
2777 1 tempheader.new_version_id_main = 2;
2778 1 tempheader.new_version_id_second = 50;
2779 1 tempheader.new_version_id_release = -1;
2780 1 break;
2781 case 25:
2782 tempheader.new_version_id_main = 2;
2783 tempheader.new_version_id_second = 50;
2784 tempheader.new_version_id_third = 1;
2785 tempheader.new_version_id_gamma = 1;
2786 break;
2787 case 26:
2788 tempheader.new_version_id_main = 2;
2789 tempheader.new_version_id_second = 50;
2790 tempheader.new_version_id_third = 1;
2791 tempheader.new_version_id_gamma = 2;
2792 break;
2793 case 27:
2794 tempheader.new_version_id_main = 2;
2795 tempheader.new_version_id_second = 50;
2796 tempheader.new_version_id_third = 1;
2797 tempheader.new_version_id_gamma = 3;
2798 break;
2799 case 28:
2800 1 tempheader.new_version_id_main = 2;
2801 1 tempheader.new_version_id_second = 50;
2802 1 tempheader.new_version_id_third = 1;
2803 1 tempheader.new_version_id_release = -1;
2804 1 break;
2805 case 29:
2806 1 tempheader.new_version_id_main = 2;
2807 1 tempheader.new_version_id_second = 50;
2808 1 tempheader.new_version_id_third = 2;
2809 1 tempheader.new_version_id_release = -1;
2810 1 break;
2811 case 30:
2812 tempheader.new_version_id_main = 2;
2813 tempheader.new_version_id_second = 50;
2814 tempheader.new_version_id_third = 3;
2815 tempheader.new_version_id_gamma = 1;
2816 break;
2817 case 31:
2818 1 tempheader.new_version_id_main = 2;
2819 1 tempheader.new_version_id_second = 53;
2820 1 tempheader.new_version_id_gamma = -1;
2821 1 break;
2822 case 32:
2823 7 tempheader.new_version_id_main = 2;
2824 7 tempheader.new_version_id_second = 53;
2825 7 tempheader.new_version_id_release = -1;
2826 7 break;
2827 case 33:
2828 tempheader.new_version_id_main = 2;
2829 tempheader.new_version_id_second = 53;
2830 tempheader.new_version_id_third = 1;
2831 break;
2832 }
2833 11 break;
2834
2835 case 0x211:
2836 tempheader.new_version_id_main = 2;
2837 tempheader.new_version_id_second = 11;
2838 tempheader.new_version_id_beta = tempheader.build;
2839 break;
2840 case 0x210:
2841 tempheader.new_version_id_main = 2;
2842 tempheader.new_version_id_second = 10;
2843 tempheader.new_version_id_beta = tempheader.build;
2844 break;
2845 }
2846 11 }
2847 }
2848
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(printmetadata || __isZQuest)
2849 {
2850 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2851 }
2852 }
2853
2854 //{ Version Warning
2855 24 int32_t vercmp = tempheader.compareVer();
2856 24 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2857 24 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2858
4/6
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
37 if(vercmp > 0 || (!vercmp &&
2859
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 (astatecmp > 0 || (!astatecmp &&
2860 13 avercmp > 0))))
2861 {
2862 bool r = true;
2863 if(loadquest_report)
2864 {
2865 enter_sys_pal();
2866 AlertDialog("Quest saved in newer version",
2867 "This quest was last saved in a newer version of ZQuest."
2868 " Attempting to load this quest may not work correctly; to"
2869 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2870 "\n\nWould you like to continue loading anyway? (Not recommended)",
2871 [&](bool ret,bool)
2872 {
2873 r = ret;
2874 }).show();
2875 exit_sys_pal();
2876 }
2877 if(!r)
2878 return qe_silenterr;
2879 }
2880
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 else if(tempheader.compareDate() > 0)
2881 {
2882 bool r = true;
2883 if(loadquest_report)
2884 {
2885 enter_sys_pal();
2886 AlertDialog("Quest saved in newer build",
2887 "This quest was last saved in a newer build of ZQuest, and may have"
2888 " issues loading in this build."
2889 "\n\nWould you like to continue loading anyway?",
2890 [&](bool ret,bool)
2891 {
2892 r = ret;
2893 }).show();
2894 exit_sys_pal();
2895 }
2896 if(!r)
2897 return qe_silenterr;
2898 }
2899 //}
2900
2901 24 read_ext_zinfo = tempheader.external_zinfo;
2902
2903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(keepdata==true)
2904 {
2905 24 memcpy(Header, &tempheader, sizeof(tempheader));
2906 24 map_count=temp_map_count;
2907 24 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2908 24 }
2909
2910 24 return 0;
2911 24 }
2912
2913 13 int32_t readrules(PACKFILE *f, zquestheader *Header, bool keepdata)
2914 {
2915 int32_t dummy;
2916 zquestheader tempheader;
2917 13 word s_version=0;
2918 13 dword compatrule_version=0;
2919
2920 13 memcpy(&tempheader, Header, sizeof(tempheader));
2921
2922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(tempheader.zelda_version >= 0x193)
2923 {
2924 //section version info
2925
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_version,f,true))
2926 {
2927 return qe_invalid;
2928 }
2929
2930 13 FFCore.quest_format[vRules] = s_version;
2931
2932
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&dummy,f,true))
2933 {
2934 return qe_invalid;
2935 }
2936
2937
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(s_version > 16)
2938 {
2939
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetl(&compatrule_version,f,true))
2940 {
2941 return qe_invalid;
2942 }
2943 2 }
2944 13 FFCore.quest_format[vCompatRule] = compatrule_version;
2945
2946 //section size
2947
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy,f,true))
2948 {
2949 return qe_invalid;
2950 }
2951
2952
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if ( s_version < 15 )
2953 {
2954 //finally... section data
2955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!pfread(quest_rules,QUESTRULES_SIZE,f,true))
2956 {
2957 return qe_invalid;
2958 }
2959 11 }
2960 else
2961 {
2962
2963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f,true))
2964 {
2965 return qe_invalid;
2966 }
2967
2968 }
2969 13 }
2970
2971 //al_trace("Rules version %d\n", s_version);
2972 //{ bunch of compat stuff
2973 13 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2974
2975
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version<2)
2976 {
2977 set_bit(quest_rules,14,0);
2978 set_bit(quest_rules,27,0);
2979 set_bit(quest_rules,28,0);
2980 set_bit(quest_rules,29,0);
2981 set_bit(quest_rules,30,0);
2982 set_bit(quest_rules,32,0);
2983 set_bit(quest_rules,36,0);
2984 set_bit(quest_rules,49,0);
2985 set_bit(quest_rules,50,0);
2986 set_bit(quest_rules,51,0);
2987 set_bit(quest_rules,68,0);
2988 set_bit(quest_rules,75,0);
2989 set_bit(quest_rules,76,0);
2990 set_bit(quest_rules,98,0);
2991 set_bit(quest_rules,110,0);
2992 set_bit(quest_rules,113,0);
2993 set_bit(quest_rules,116,0);
2994 set_bit(quest_rules,102,0);
2995 set_bit(quest_rules,132,0);
2996 }
2997
2998 //Now, do any updates...
2999
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3000 {
3001 set_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING,1);
3002 set_bit(quest_rules, qr_REPLACEOPENDOORS, 1);
3003 set_bit(quest_rules, qr_OLDLENSORDER, 1);
3004 set_bit(quest_rules, qr_NOFAIRYGUYFIRES, 1);
3005 set_bit(quest_rules, qr_TRIGGERSREPEAT, 1);
3006 }
3007
3008
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3009 {
3010 set_bit(quest_rules,qr_WALLFLIERS,1);
3011 }
3012
3013
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3014 {
3015 set_bit(quest_rules,qr_NOBOMBPALFLASH,1);
3016 }
3017
3018
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3019 {
3020 set_bit(quest_rules,qr_NOSCROLLCONTINUE,1);
3021 }
3022
3023
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(tempheader.zelda_version <= 0x210)
3024 {
3025 set_bit(quest_rules,qr_ARROWCLIP,1);
3026 }
3027
3028
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(tempheader.zelda_version == 0x210)
3029 {
3030 set_bit(quest_rules, qr_NOSCROLLCONTINUE, get_bit(quest_rules, qr_CMBCYCLELAYERS));
3031 set_bit(quest_rules, qr_CMBCYCLELAYERS, 0);
3032 set_bit(quest_rules, qr_CONT_SWORD_TRIGGERS, 1);
3033 }
3034
3035
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(tempheader.zelda_version <= 0x210)
3036 {
3037 set_bit(quest_rules,qr_OLDSTYLEWARP,1);
3038 set_bit(quest_rules,qr_210_WARPRETURN,1);
3039 }
3040
3041 //might not be correct
3042
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(tempheader.zelda_version < 0x210)
3043 {
3044 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3045 set_bit(quest_rules, qr_OLDHOOKSHOTGRAB,1);
3046 }
3047
3048
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(tempheader.zelda_version < 0x211)
3049 {
3050 set_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR,1);
3051 }
3052
3053
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3054 {
3055 set_bit(quest_rules, qr_192b163_WARP,1);
3056 }
3057
3058
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(tempheader.zelda_version == 0x210)
3059 {
3060 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_bit(quest_rules, qr_DMGCOMBOPRI));
3061 set_bit(quest_rules, qr_DMGCOMBOPRI, 0);
3062 }
3063
3064
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3065 {
3066 set_bit(quest_rules, qr_OLDPICKUP,1);
3067 }
3068
3069
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3070 {
3071 set_bit(quest_rules,qr_NOSOLIDDAMAGECOMBOS, 1);
3072 set_bit(quest_rules, qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3073 }
3074
3075
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3076 {
3077 set_bit(quest_rules,qr_HOOKSHOTDOWNBUG, 1);
3078 }
3079
3080
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
13 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3081 {
3082 1 set_bit(quest_rules,qr_PEAHATCLOCKVULN, 1);
3083 1 }
3084
3085
4/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11 times.
13 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3086 {
3087 set_bit(quest_rules,qr_OLD_DOORREPAIR, 1);
3088 }
3089
3090
4/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11 times.
13 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3091 {
3092 set_bit(quest_rules,qr_OLD_SECRETMONEY, 1);
3093 }
3094
3095
5/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 10 times.
13 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3096 {
3097 1 set_bit(quest_rules,qr_OLD_POTION_OR_HC, 1);
3098 1 }
3099
3100
5/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 10 times.
13 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3101 {
3102 1 set_bit(quest_rules, qr_OFFSCREENWEAPONS, 1);
3103 1 }
3104
3105 //Bombchu fix.
3106
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(tempheader.zelda_version == 0x250)
3107 {
3108
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 if ( tempheader.build == 24 ) //2.50.0
3109 {
3110 1 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3111 1 }
3112
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 if ( tempheader.build == 28 ) //2.50.1
3113 {
3114 1 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3115 1 }
3116
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 if ( tempheader.build == 29 ) //2.50.2
3117 {
3118 1 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3119 1 }
3120
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( tempheader.build == 30 ) //2.50.3RC1
3121 {
3122 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3123 }
3124 11 }
3125
3126
5/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 9 times.
13 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3127 {
3128 // qr_OFFSETEWPNCOLLISIONFIX
3129 // All 'official' quests need this disabled.
3130 // All 2.10 and lower quests need this enabled to preseve compatability.
3131 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3132
3133 //~Gleeok
3134 2 set_bit(quest_rules, qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3135
3136 // Broke in build 695
3137
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3138 2 set_bit(quest_rules, qr_BROKENSTATUES, 1);
3139 2 }
3140
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (tempheader.zelda_version <= 0x190)
3141 {
3142 set_bit(quest_rules, qr_COPIED_SWIM_SPRITES, 1);
3143 }
3144
6/10
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
13 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3145 {
3146 11 set_bit(quest_rules, qr_OLD_SLASHNEXT_SECRETS, 1);
3147 11 }
3148
3149
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3150 {
3151 set_bit(quest_rules, qr_OLD_210_WATER, 1);
3152 }
3153
3154
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3155 {
3156 11 set_bit(quest_rules,qr_STEP_IS_FLOAT,0);
3157 11 }
3158
3159
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if ( tempheader.zelda_version < 0x250 )
3160 {
3161 set_bit(quest_rules, qr_8WAY_SHOT_SFX, 1);
3162 }
3163
3164
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version < 3)
3165 {
3166 set_bit(quest_rules, qr_HOLDNOSTOPMUSIC, 1);
3167 set_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC, 1);
3168 }
3169
3170
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version<4)
3171 {
3172 set_bit(quest_rules,10,0);
3173 }
3174
3175
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version<5)
3176 {
3177 set_bit(quest_rules,27,0);
3178 }
3179
3180
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version<6)
3181 {
3182 set_bit(quest_rules,46,0);
3183 }
3184
3185
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version<7) // January 2008
3186 {
3187 set_bit(quest_rules,qr_HEARTSREQUIREDFIX,0);
3188 set_bit(quest_rules,qr_PUSHBLOCKCSETFIX,1);
3189 }
3190
3191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version<8)
3192 {
3193 set_bit(quest_rules, 12, 0);
3194 }
3195 else
3196 {
3197 13 set_bit(deprecated_rules, 12, 0);
3198 }
3199
3200
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version<9) // October 2008
3201 {
3202 set_bit(quest_rules,qr_NOROPE2FLASH_DEP,0);
3203 set_bit(quest_rules,qr_NOBUBBLEFLASH_DEP,0);
3204 set_bit(quest_rules,qr_GHINI2BLINK_DEP,0);
3205 set_bit(quest_rules,qr_PHANTOMGHINI2_DEP,0);
3206 }
3207
3208
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version<10) // December 2008
3209 {
3210 set_bit(quest_rules,qr_NOCLOCKS_DEP,0);
3211 set_bit(quest_rules, qr_ALLOW10RUPEEDROPS_DEP,0);
3212 }
3213
3214
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version<11) // April 2009
3215 {
3216 set_bit(quest_rules,qr_SLOWENEMYANIM_DEP,0);
3217 }
3218
3219
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version<12) // December 2009
3220 {
3221 set_bit(quest_rules,qr_BRKBLSHLDS_DEP,0);
3222 set_bit(quest_rules, qr_OLDTRIBBLES_DEP,0);
3223 }
3224
3225 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3226
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version < 13)
3227 {
3228 set_bit(quest_rules,qr_SHOPCHEAT, 1);
3229 }
3230
3231 // Not entirely sure this is the best place for this...
3232 //2.50.2 bitmap offset fix
3233 13 memset(extra_rules, 0, EXTRARULES_SIZE);
3234
5/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 9 times.
13 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3235 {
3236 2 set_bit(extra_rules, er_BITMAPOFFSET, 1);
3237 2 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 1);
3238 2 }
3239 //required because quest templates also used this bit, although
3240 //it never did anything, before. -Z
3241
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if ( tempheader.zelda_version == 0x250 )
3242 {
3243
5/6
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 9 times.
11 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3244 {
3245 2 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3246 2 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3247 2 }
3248 11 }
3249
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if ( tempheader.zelda_version == 0x254 )
3250 {
3251 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3252 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3253 }
3254
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
13 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3255 {
3256 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3257 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3258 }
3259 //optimise fast drawing for older versions.
3260
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3261 {
3262 11 set_bit(quest_rules, qr_OLDSPRITEDRAWS, 1);
3263 11 }
3264 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3265 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3266 //older quests can set the rule by hand. We need a new qst.dat again.
3267
4/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3268 {
3269 set_bit(quest_rules, qr_OLDEWPNPARENT, 1);
3270 }
3271
4/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3272 {
3273 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 1);
3274 }
3275
4/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3276 {
3277 set_bit(quest_rules, qr_OLDQUESTMISC, 1);
3278 }
3279
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if ( tempheader.zelda_version < 0x254 )
3280 {
3281 11 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 0);
3282 11 set_bit(quest_rules, qr_OLDEWPNPARENT, 0);
3283 11 set_bit(quest_rules, qr_OLDQUESTMISC, 0);
3284 11 }
3285
3286 //item scripts continue to run
3287
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3288 {
3289 11 set_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING, 0);
3290 11 set_bit(quest_rules, qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3291 11 set_bit(quest_rules, qr_FIXSCRIPTSDURINGSCROLLING, 0);
3292 11 set_bit(quest_rules, qr_SCRIPTDRAWSINWARPS, 0);
3293 11 set_bit(quest_rules, qr_DYINGENEMYESDONTHURTHERO, 0);
3294 11 set_bit(quest_rules, qr_OUTOFBOUNDSENEMIES, 0);
3295 11 set_bit(quest_rules, qr_SPRITEXY_IS_FLOAT, 0);
3296 11 }
3297
3298
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3299 {
3300 11 set_bit(quest_rules, qr_CLEARINITDONSCRIPTCHANGE, 1);
3301 11 }
3302
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3303 {
3304 11 set_bit(quest_rules, qr_TRACESCRIPTIDS, 0);
3305 11 set_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3306 11 set_bit(quest_rules, qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3307 11 set_bit(quest_rules,qr_PARSER_250DIVISION,1);
3308 11 set_bit(quest_rules,qr_PARSER_BOOL_TRUE_DECIMAL,1);
3309 11 set_bit(quest_rules,qr_PARSER_TRUE_INT_SIZE,0);
3310 11 set_bit(quest_rules,qr_PARSER_FORCE_INLINE,0);
3311 11 set_bit(quest_rules,qr_PARSER_BINARY_32BIT,0);
3312
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( get_bit(quest_rules, qr_SELECTAWPN) )
3313 {
3314 set_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3315 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3316 //Now they **do**, unless you disable that behaviour.
3317 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3318 //now enable the disable L/R item swap on load.
3319 }
3320
3321 11 }
3322
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3323 {
3324 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3325 11 set_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING, 1);
3326 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3327 //animations ending earlier than they should.
3328 11 set_bit(quest_rules, qr_BROKEN_ASKIP_Y_FRAMES, 1);
3329 //Enemies would ignore solidity on the top half of combos
3330 11 set_bit(quest_rules, qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3331 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3332 11 set_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3333 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3334 11 set_bit(quest_rules, qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3335 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3336 11 set_bit(quest_rules, qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3337 11 }
3338
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if ( tempheader.zelda_version < 0x255 )
3339 {
3340 11 set_bit(quest_rules, qr_NOFFCWAITDRAW, 1);
3341 11 set_bit(quest_rules, qr_NOITEMWAITDRAW, 1);
3342 11 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3343 11 set_bit(quest_rules, qr_OLD_INIT_SCRIPT_TIMING, 1);
3344 //set_bit(quest_rules, qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3345 11 }
3346
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3347 {
3348 11 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3349 11 }
3350
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3351 {
3352 11 set_bit(quest_rules, qr_OLD_PRINTF_ARGS, 1);
3353 11 }
3354
3355
3356
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3357 {
3358 11 set_bit(quest_rules, qr_BROKEN_RING_POWER, 1);
3359 11 }
3360
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3361 {
3362 11 set_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING, 1);
3363 11 }
3364
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3365 {
3366 11 set_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3367 11 }
3368
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3369 {
3370 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3371
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
3372 set_bit(quest_rules,qr_SET_YBUTTON_ITEMS,1);
3373 11 }
3374
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3375 {
3376 11 set_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0,1);
3377 11 }
3378
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3379 {
3380 11 set_bit(quest_rules,qr_OLD_CHEST_COLLISION,1);
3381 11 }
3382
3383
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if ( tempheader.zelda_version < 0x254 )
3384 {
3385 11 set_bit(quest_rules, qr_250WRITEEDEFSCRIPT, 1);
3386 11 }
3387 //Sideview spikes in 2.50.0
3388
5/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 10 times.
13 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3389 {
3390 1 set_bit(quest_rules, qr_OLDSIDEVIEWSPIKES, 1);
3391 1 }
3392 //more 2.50 fixes -Z
3393
5/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 8 times.
13 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3394 {
3395 3 set_bit(quest_rules, qr_MELEEMAGICCOST, 0);
3396 3 set_bit(quest_rules, qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3397 3 set_bit(quest_rules, qr_OLDMIRRORCOMBOS, 1);
3398 3 set_bit(quest_rules, qr_BROKENBOOKCOST, 1);
3399 3 set_bit(quest_rules, qr_BROKENCHARINTDRAWING, 1);
3400
3401 3 }
3402
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3403 {
3404 //set_bit(quest_rules,qr_MELEEMAGICCOST, get_bit(extra_rules,er_MAGICCOSTSWORD));
3405 set_bit(quest_rules,qr_MELEEMAGICCOST, 1);
3406 }
3407
3408
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(tempheader.zelda_version < 0x193)
3409 {
3410 set_bit(quest_rules, qr_SHORTDGNWALK, 1);
3411 }
3412
3413
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(tempheader.zelda_version < 0x255)
3414 {
3415 11 set_bit(quest_rules, qr_OLDINFMAGIC, 1);
3416 11 }
3417
3418
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3419 {
3420 set_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR,1);
3421 }
3422
3423
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3424 {
3425 11 set_bit(quest_rules,qr_OLD_F6,1);
3426 11 }
3427
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3428 {
3429 11 set_bit(quest_rules,qr_NO_OVERWRITING_HOPPING,1);
3430 11 }
3431
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3432 {
3433 11 set_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3434 11 }
3435
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3436 {
3437 11 set_bit(quest_rules,qr_BROKEN_OVERWORLD_MINIMAP,1);
3438 11 }
3439 //}
3440
3441
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 1)
3442 {
3443 //Enemies->Secret only affects flag 16-31
3444 11 set_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31,1);
3445 11 }
3446
3447
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 2)
3448 {
3449 //Old CSet2 Handling
3450 11 set_bit(quest_rules,qr_OLDCS2,1);
3451 11 }
3452
3453
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 3)
3454 {
3455 //Hardcoded Shadow/Spawn/Death anim frames
3456 11 set_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS,1);
3457 11 }
3458
3459
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 4)
3460 {
3461 //Hardcoded Shadow/Spawn/Death anim frames
3462 11 set_bit(quest_rules,qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3463 11 }
3464
3465
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
13 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250)
3466 {
3467 //Hardcoded Shadow/Spawn/Death anim frames
3468 11 set_bit(quest_rules,qr_NO_LANMOLA_RINGLEADER,1);
3469 11 }
3470
3471
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 6)
3472 {
3473 //Step->Secret (Temp) only affects flag 16-31
3474 11 set_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31,1);
3475 11 }
3476
3477
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 7)
3478 {
3479 //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3480 11 set_bit(quest_rules,qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3481 11 }
3482
3483
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 8)
3484 {
3485 //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3486 11 set_bit(quest_rules,qr_HARDCODED_LITEM_LTMS,1);
3487 11 }
3488
3489
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 9)
3490 {
3491 //Hardcoded BS Patras
3492 11 set_bit(quest_rules,qr_HARDCODED_BS_PATRA,1);
3493 //Hardcoded Patra Inner Eye offsets
3494 11 set_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3495 //Broken 'Big enemy' animation style
3496 11 set_bit(quest_rules,qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3497 //Broken Attribute 31/32
3498 11 set_bit(quest_rules,qr_BROKEN_ATTRIBUTE_31_32,1);
3499 11 }
3500
3501
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 10)
3502 {
3503 //Shared candle use limits
3504 11 set_bit(quest_rules,qr_CANDLES_SHARED_LIMIT,1);
3505 11 }
3506
3507
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 11)
3508 {
3509 //No cross-screen return points
3510 11 set_bit(quest_rules,qr_OLD_RESPAWN_POINTS,1);
3511 11 }
3512
3513
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 12)
3514 {
3515 //Old fire trail duration
3516 11 set_bit(quest_rules,qr_OLD_FLAMETRAIL_DURATION,1);
3517 //Old Intro String in Ganon Room Behavior
3518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(get_bit(quest_rules,qr_GANONINTRO)) set_bit(quest_rules,qr_GANONINTRO,0);
3519 11 else set_bit(quest_rules,qr_GANONINTRO,1);
3520 11 }
3521
3522
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
13 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255)
3523 {
3524 //ANone doesn't reset to originaltile
3525 set_bit(quest_rules,qr_ANONE_NOANIM,1);
3526 }
3527
3528
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 14)
3529 {
3530 //Old Bridge Combo Behavior
3531 11 set_bit(quest_rules,qr_OLD_BRIDGE_COMBOS,1);
3532 11 }
3533
3534
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 15)
3535 {
3536 //Broken Z3 Animation
3537 11 set_bit(quest_rules,qr_BROKEN_Z3_ANIMATION,1);
3538 11 }
3539
3540
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 16)
3541 {
3542 //Old Enemy Tile Behavior with Animation (None) Enemies
3543 11 set_bit(quest_rules,qr_OLD_TILE_INITIALIZATION,1);
3544 11 }
3545
3546
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 17)
3547 {
3548 //Old Quake/DrawYOffset behavior
3549 //set_bit(quest_rules,qr_OLD_DRAWOFFSET,1);
3550 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3551 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3552 11 }
3553
3554
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 18)
3555 {
3556 //Broken DrawScreen Derivative Functions
3557 11 set_bit(quest_rules,qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3558 //Scrolling Cancels Charge
3559 11 set_bit(quest_rules,qr_SCROLLING_KILLS_CHARGE,1);
3560 11 }
3561
3562
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 19)
3563 {
3564 //Broken Enemy Item Carrying with Large Enemies
3565 11 set_bit(quest_rules,qr_BROKEN_ITEM_CARRYING,1);
3566 11 }
3567
3568
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 20)
3569 {
3570 11 set_bit(quest_rules,qr_CUSTOMWEAPON_IGNORE_COST,1);
3571 11 }
3572
3573
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 21)
3574 {
3575 11 set_bit(quest_rules,qr_LEEVERS_DONT_OBEY_STUN,1);
3576 11 set_bit(quest_rules,qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3577 11 set_bit(quest_rules,qr_WIZZROBES_DONT_OBEY_STUN,1);
3578 11 set_bit(quest_rules,qr_OLD_BUG_NET,1);
3579 11 set_bit(quest_rules,qr_MANHANDLA_BLOCK_SFX,1);
3580 11 }
3581
3582
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 22)
3583 {
3584 11 set_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG,1);
3585 11 }
3586
3587
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 23)
3588 {
3589 11 set_bit(quest_rules,qr_OLD_HALF_MAGIC,1);
3590 11 }
3591
3592
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 24)
3593 {
3594 11 set_bit(quest_rules,qr_WARPS_RESTART_DMAPSCRIPT,1);
3595 11 set_bit(quest_rules,qr_DMAP_0_CONTINUE_BUG,1);
3596 11 }
3597
3598
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 25)
3599 {
3600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (get_bit(quest_rules, qr_OLD_FAIRY_LIMIT)) set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,0);
3601 11 else set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,1);
3602 11 set_bit(quest_rules,qr_OLD_SCRIPTED_KNOCKBACK,1);
3603 11 }
3604
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 26)
3605 {
3606 11 set_bit(quest_rules,qr_OLD_KEESE_Z_AXIS,1);
3607 11 set_bit(quest_rules,qr_POLVIRE_NO_SHADOW,1);
3608 11 set_bit(quest_rules,qr_SUBSCR_OLD_SELECTOR,1);
3609 11 }
3610
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3611 {
3612
2/2
✓ Branch 0 taken 3311 times.
✓ Branch 1 taken 11 times.
3322 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3613 3311 set_bit(quest_rules,q,0);
3614
2/2
✓ Branch 0 taken 1232 times.
✓ Branch 1 taken 11 times.
1243 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3615 1232 set_bit(quest_rules,q,0);
3616 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3617 11 }
3618
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 28)
3619 {
3620 11 set_bit(quest_rules,qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3621 11 }
3622
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 29)
3623 {
3624 11 set_bit(quest_rules,qr_OLD_LOCKBLOCK_COLLISION,1);
3625 11 }
3626
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 30)
3627 {
3628 11 set_bit(quest_rules,qr_DECO_2_YOFFSET,1);
3629 11 set_bit(quest_rules,qr_SCREENSTATE_80s_BUG,1);
3630 11 }
3631
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 31)
3632 {
3633 11 set_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG,1);
3634 11 set_bit(quest_rules,qr_FFCPRELOAD_BUGGED_LOAD,1);
3635 11 }
3636
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 32)
3637 {
3638 11 set_bit(quest_rules,qr_BROKEN_GETPIXEL_VALUE,1);
3639 11 }
3640
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(compatrule_version < 33)
3641 {
3642 11 set_bit(quest_rules,qr_NO_LIFT_SPRITE,1);
3643 11 }
3644
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if(compatrule_version < 34)
3645 {
3646 12 set_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE,1);
3647 12 set_bit(quest_rules,qr_OLD_FFC_SPEED_CAP,1);
3648 12 set_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING,1);
3649 12 }
3650
3651 //always set
3652 13 set_bit(quest_rules,qr_ANIMATECUSTOMWEAPONS,0);
3653
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if (s_version < 16) set_bit(quest_rules,qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata==true)
3655 {
3656 13 memcpy(Header, &tempheader, sizeof(tempheader));
3657 13 }
3658 13 return 0;
3659 13 }
3660
3661 106983 void init_msgstr(MsgStr *str)
3662 {
3663 106983 str->s = "";
3664 106983 str->s.shrink_to_fit();
3665 106983 str->nextstring=0;
3666 106983 str->tile=0;
3667 106983 str->cset=0;
3668 106983 str->trans=false;
3669 106983 str->font=font_zfont;
3670 106983 str->y=32;
3671 106983 str->sfx=18;
3672 106983 str->listpos=0;
3673 106983 str->x=24;
3674 106983 str->w=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3675 106983 str->h=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3676 106983 str->hspace=0;
3677 106983 str->vspace=0;
3678 106983 str->stringflags=0;
3679 106983 str->margins[up] = 8;
3680 106983 str->margins[down] = 0;
3681 106983 str->margins[left] = 8;
3682 106983 str->margins[right] = 0;
3683 106983 str->portrait_tile = 0;
3684 106983 str->portrait_cset = 0;
3685 106983 str->portrait_x = 0;
3686 106983 str->portrait_y = 0;
3687 106983 str->portrait_tw = 1;
3688 106983 str->portrait_th = 1;
3689 106983 str->shadow_type = 0;
3690 106983 str->shadow_color = 0;
3691 106983 str->drawlayer = 6;
3692 106983 }
3693
3694 13 void init_msgstrings(int32_t start, int32_t end)
3695 {
3696
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(end <= start || end-start > msg_strings_size)
3697 return;
3698
3699
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 13 times.
106509 for(int32_t i=start; i<end; i++)
3700 {
3701 106496 init_msgstr(&MsgStrings[i]);
3702 106496 MsgStrings[i].listpos=i;
3703 106496 }
3704
3705
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(start==0)
3706 {
3707 13 MsgStrings[0].s = "(None)";
3708 13 MsgStrings[0].listpos = 0;
3709 13 }
3710 13 }
3711
3712 13 int32_t readstrings(PACKFILE *f, zquestheader *Header, bool keepdata)
3713 {
3714 13 MsgStr tempMsgString;
3715
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 init_msgstr(&tempMsgString);
3716
3717 13 word temp_msg_count=0;
3718 word temp_expansion[16];
3719 13 memset(temp_expansion, 0, 16*sizeof(word));
3720 13 char buf[8193] = {0};
3721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(Header->zelda_version < 0x193)
3722 {
3723 byte tempbyte;
3724 int32_t strings_to_read=0;
3725 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3726 if((Header->zelda_version < 0x192)||
3727 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3728 {
3729 strings_to_read=128;
3730 temp_msg_count=Header->old_str_count;
3731
3732 // Some sort of string count corruption seems to be common in old quests
3733 if(temp_msg_count>128)
3734 {
3735 temp_msg_count=128;
3736 }
3737 }
3738 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3739 {
3740 strings_to_read=255;
3741 temp_msg_count=Header->old_str_count;
3742 }
3743 else
3744 {
3745 if(!p_igetw(&temp_msg_count,f,true))
3746 {
3747 return qe_invalid;
3748 }
3749
3750 strings_to_read=temp_msg_count;
3751
3752 if(temp_msg_count >= msg_strings_size)
3753 {
3754 Z_message("Reallocating string buffer...\n");
3755
3756 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3757 // return qe_nomem;
3758
3759 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3760 delete[] MsgStrings;
3761 MsgStrings = new MsgStr[MAXMSGS];
3762 msg_strings_size = MAXMSGS;
3763 for(auto q = 0; q < msg_strings_size; ++q)
3764 {
3765 MsgStrings[q].clear();
3766 }
3767 }
3768 }
3769
3770 //reset the message strings
3771 if(keepdata)
3772 {
3773 init_msgstrings(0,msg_strings_size);
3774 }
3775
3776 for(int32_t x=0; x<strings_to_read; x++)
3777 {
3778 init_msgstr(&tempMsgString);
3779
3780 if(!pfread(buf,73,f,true))
3781 {
3782 return qe_invalid;
3783 }
3784
3785 buf[74] = '\0';
3786 tempMsgString.s = buf;
3787
3788 if(!p_getc(&tempbyte,f,true))
3789 {
3790 return qe_invalid;
3791 }
3792
3793 if((Header->zelda_version < 0x192)||
3794 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3795 {
3796 tempMsgString.nextstring=tempbyte?x+1:0;
3797
3798 if(!p_getc(&tempbyte,f,true))
3799 {
3800 return qe_invalid;
3801 }
3802
3803 if(!p_getc(&tempbyte,f,true))
3804 {
3805 return qe_invalid;
3806 }
3807 }
3808 else
3809 {
3810 if(!p_igetw(&tempMsgString.nextstring,f,true))
3811 {
3812 return qe_invalid;
3813 }
3814
3815 if(!pfread(temp_expansion,32,f,true))
3816 {
3817 return qe_invalid;
3818 }
3819 }
3820
3821 if(keepdata==true)
3822 {
3823 MsgStrings[x] = tempMsgString;
3824 }
3825 }
3826 }
3827 else
3828 {
3829 int32_t dummy_int;
3830 word s_version;
3831 word s_cversion;
3832
3833 //section version info
3834
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&s_version,f,true))
3835 {
3836 return qe_invalid;
3837 }
3838
3839 13 FFCore.quest_format[vStrings] = s_version;
3840
3841
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&s_cversion,f,true))
3842 {
3843 return qe_invalid;
3844 }
3845
3846 //al_trace("Strings version %d\n", s_version);
3847 //section size
3848
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetl(&dummy_int,f,true))
3849 {
3850 return qe_invalid;
3851 }
3852
3853 //finally... section data
3854
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_msg_count,f,true))
3855 {
3856 return qe_invalid;
3857 }
3858
3859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(temp_msg_count >= msg_strings_size)
3860 {
3861 Z_message("Reallocating string buffer...\n");
3862
3863 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3864 // return qe_nomem;
3865 delete[] MsgStrings;
3866 MsgStrings = new MsgStr[MAXMSGS];
3867 msg_strings_size = MAXMSGS;
3868 for(auto q = 0; q < msg_strings_size; ++q)
3869 {
3870 MsgStrings[q].clear();
3871 }
3872 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3873 }
3874
3875 //reset the message strings
3876
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(keepdata)
3877 {
3878
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(s_version < 7)
3879
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3880
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 init_msgstrings(0,msg_strings_size);
3881 13 }
3882
3883 13 int32_t string_length=(s_version<2)?73:145;
3884
3885
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 13 times.
487 for(int32_t i=0; i<temp_msg_count; i++)
3886 {
3887
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 init_msgstr(&tempMsgString);
3888
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 470 times.
474 if(s_version > 8)
3889 {
3890
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!p_igetl(&string_length,f,true))
3891 {
3892 return qe_invalid;
3893 }
3894 4 }
3895
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if (string_length > 0)
3896 {
3897
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if (!pfread(buf, string_length, f, true))
3898 {
3899 return qe_invalid;
3900 }
3901 474 }
3902 else
3903 {
3904 buf[0] = 0;
3905 }
3906
3907
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&tempMsgString.nextstring,f,true))
3908 {
3909 return qe_invalid;
3910 }
3911
3912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(s_version<2)
3913 {
3914 buf[72] = '\0';
3915 tempMsgString.s = buf;
3916 }
3917 else
3918 {
3919 // June 2008: A bug corrupted the last 4 chars of a string.
3920 // Discard these.
3921
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(s_version<3)
3922 {
3923 for(int32_t j=140; j<144; j++)
3924 {
3925 buf[j] = '\0';
3926 }
3927 }
3928
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(string_length > 8192) string_length = 8192;
3929 474 buf[string_length]='\0'; //Force-terminate
3930
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 tempMsgString.s = buf;
3931
3932
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 470 times.
474 if ( s_version >= 6 )
3933 {
3934
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!p_igetl(&tempMsgString.tile,f,true))
3935 {
3936 return qe_invalid;
3937 }
3938 4 }
3939 else
3940 {
3941
2/4
✓ Branch 0 taken 470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 470 times.
✗ Branch 3 not taken.
470 if(!p_igetw(&tempMsgString.tile,f,true))
3942 {
3943 return qe_invalid;
3944 }
3945 }
3946
3947
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_getc(&tempMsgString.cset,f,true))
3948 {
3949 return qe_invalid;
3950 }
3951
3952 byte dummy_char;
3953
3954
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_getc(&dummy_char,f,true)) // trans is stored as a char...
3955 {
3956 return qe_invalid;
3957 }
3958
3959 474 tempMsgString.trans=dummy_char!=0;
3960
3961
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_getc(&tempMsgString.font,f,true))
3962 {
3963 return qe_invalid;
3964 }
3965
3966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 if(s_version < 5)
3967 {
3968 if(!p_getc(&tempMsgString.y,f,true))
3969 {
3970 return qe_invalid;
3971 }
3972 }
3973 else
3974 {
3975
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&tempMsgString.x,f,true))
3976 {
3977 return qe_invalid;
3978 }
3979
3980
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&tempMsgString.y,f,true))
3981 {
3982 return qe_invalid;
3983 }
3984
3985
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&tempMsgString.w,f,true))
3986 {
3987 return qe_invalid;
3988 }
3989
3990
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&tempMsgString.h,f,true))
3991 {
3992 return qe_invalid;
3993 }
3994
3995
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_getc(&tempMsgString.hspace,f,true))
3996 {
3997 return qe_invalid;
3998 }
3999
4000
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_getc(&tempMsgString.vspace,f,true))
4001 {
4002 return qe_invalid;
4003 }
4004
4005
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_getc(&tempMsgString.stringflags,f,true))
4006 {
4007 return qe_invalid;
4008 }
4009 }
4010
4011
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 4 times.
474 if(s_version >= 7)
4012 {
4013
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 for(int32_t q = 0; q < 4; ++q)
4014 {
4015
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 if(!p_getc(&tempMsgString.margins[q],f,true))
4016 {
4017 return qe_invalid;
4018 }
4019 16 }
4020
4021
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!p_igetl(&tempMsgString.portrait_tile,f,true))
4022 {
4023 return qe_invalid;
4024 }
4025
4026
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!p_getc(&tempMsgString.portrait_cset,f,true))
4027 {
4028 return qe_invalid;
4029 }
4030
4031
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!p_getc(&tempMsgString.portrait_x,f,true))
4032 {
4033 return qe_invalid;
4034 }
4035
4036
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!p_getc(&tempMsgString.portrait_y,f,true))
4037 {
4038 return qe_invalid;
4039 }
4040
4041
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!p_getc(&tempMsgString.portrait_tw,f,true))
4042 {
4043 return qe_invalid;
4044 }
4045
4046
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!p_getc(&tempMsgString.portrait_th,f,true))
4047 {
4048 return qe_invalid;
4049 }
4050 4 }
4051
4052
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 470 times.
474 if(s_version >= 8)
4053 {
4054
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!p_getc(&tempMsgString.shadow_type,f,true))
4055 {
4056 return qe_invalid;
4057 }
4058
4059
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!p_getc(&tempMsgString.shadow_color,f,true))
4060 {
4061 return qe_invalid;
4062 }
4063 4 }
4064
4065
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 470 times.
474 if(s_version >= 10)
4066 {
4067
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!p_getc(&tempMsgString.drawlayer,f,true))
4068 {
4069 return qe_invalid;
4070 }
4071 4 }
4072
4073
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_getc(&tempMsgString.sfx,f,true))
4074 {
4075 return qe_invalid;
4076 }
4077
4078
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(s_version>3)
4079 {
4080
2/4
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 474 times.
✗ Branch 3 not taken.
474 if(!p_igetw(&tempMsgString.listpos,f,true))
4081 {
4082 return qe_invalid;
4083 }
4084 474 }
4085 }
4086
4087
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 if(keepdata==true)
4088 {
4089
1/2
✓ Branch 0 taken 474 times.
✗ Branch 1 not taken.
474 MsgStrings[i].copyAll(tempMsgString);
4090 474 }
4091 474 }
4092 }
4093
4094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata==true)
4095 {
4096 13 msg_count=temp_msg_count;
4097 13 }
4098
4099 13 return 0;
4100 13 }
4101
4102 13 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header, bool keepdata)
4103 {
4104
1/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if((Header->zelda_version < 0x192)||
4105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4106 {
4107 return 0;
4108 }
4109
4110 13 word temp_door_combo_set_count=0;
4111 DoorComboSet tempDoorComboSet;
4112 word dummy_word;
4113 int32_t dummy_long;
4114 byte padding;
4115 13 int32_t s_version = 0;
4116
4117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata==true)
4118 {
4119
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4120 {
4121 3328 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4122 3328 }
4123 13 }
4124
4125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(Header->zelda_version > 0x192)
4126 {
4127 //section version info
4128
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_version,f,true))
4129 {
4130 return qe_invalid;
4131 }
4132
4133 13 FFCore.quest_format[vDoors] = s_version;
4134
4135 //al_trace("Door combo sets version %d\n", dummy_word);
4136
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&dummy_word,f,true))
4137 {
4138 return qe_invalid;
4139 }
4140
4141 //section size
4142
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy_long,f,true))
4143 {
4144 return qe_invalid;
4145 }
4146 13 }
4147
4148 //finally... section data
4149
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&temp_door_combo_set_count,f,true))
4150 {
4151 return qe_invalid;
4152 }
4153
4154
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 13 times.
56 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4155 {
4156 43 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4157
4158 //name
4159
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f,true))
4160 {
4161 return qe_invalid;
4162 }
4163
4164
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 if(Header->zelda_version < 0x193)
4165 {
4166 if(!p_getc(&padding,f,true))
4167 {
4168 return qe_invalid;
4169 }
4170 }
4171
4172 //up door
4173
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 43 times.
430 for(int32_t j=0; j<9; j++)
4174 {
4175
2/2
✓ Branch 0 taken 1548 times.
✓ Branch 1 taken 387 times.
1935 for(int32_t k=0; k<4; k++)
4176 {
4177
1/2
✓ Branch 0 taken 1548 times.
✗ Branch 1 not taken.
1548 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f,true))
4178 {
4179 return qe_invalid;
4180 }
4181 1548 }
4182 387 }
4183
4184
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 43 times.
430 for(int32_t j=0; j<9; j++)
4185 {
4186
2/2
✓ Branch 0 taken 1548 times.
✓ Branch 1 taken 387 times.
1935 for(int32_t k=0; k<4; k++)
4187 {
4188
1/2
✓ Branch 0 taken 1548 times.
✗ Branch 1 not taken.
1548 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f,true))
4189 {
4190 return qe_invalid;
4191 }
4192 1548 }
4193 387 }
4194
4195 //down door
4196
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 43 times.
430 for(int32_t j=0; j<9; j++)
4197 {
4198
2/2
✓ Branch 0 taken 1548 times.
✓ Branch 1 taken 387 times.
1935 for(int32_t k=0; k<4; k++)
4199 {
4200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1548 times.
1548 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f,true))
4201 {
4202 return qe_invalid;
4203 }
4204 1548 }
4205 387 }
4206
4207
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 43 times.
430 for(int32_t j=0; j<9; j++)
4208 {
4209
2/2
✓ Branch 0 taken 1548 times.
✓ Branch 1 taken 387 times.
1935 for(int32_t k=0; k<4; k++)
4210 {
4211
1/2
✓ Branch 0 taken 1548 times.
✗ Branch 1 not taken.
1548 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f,true))
4212 {
4213 return qe_invalid;
4214 }
4215 1548 }
4216 387 }
4217
4218 //left door
4219
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 43 times.
430 for(int32_t j=0; j<9; j++)
4220 {
4221
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 387 times.
2709 for(int32_t k=0; k<6; k++)
4222 {
4223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2322 times.
2322 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f,true))
4224 {
4225 return qe_invalid;
4226 }
4227 2322 }
4228 387 }
4229
4230
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 43 times.
430 for(int32_t j=0; j<9; j++)
4231 {
4232
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 387 times.
2709 for(int32_t k=0; k<6; k++)
4233 {
4234
1/2
✓ Branch 0 taken 2322 times.
✗ Branch 1 not taken.
2322 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f,true))
4235 {
4236 return qe_invalid;
4237 }
4238 2322 }
4239 387 }
4240
4241 //right door
4242
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 43 times.
430 for(int32_t j=0; j<9; j++)
4243 {
4244
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 387 times.
2709 for(int32_t k=0; k<6; k++)
4245 {
4246
1/2
✓ Branch 0 taken 2322 times.
✗ Branch 1 not taken.
2322 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f,true))
4247 {
4248 return qe_invalid;
4249 }
4250 2322 }
4251 387 }
4252
4253
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 43 times.
430 for(int32_t j=0; j<9; j++)
4254 {
4255
2/2
✓ Branch 0 taken 2322 times.
✓ Branch 1 taken 387 times.
2709 for(int32_t k=0; k<6; k++)
4256 {
4257
1/2
✓ Branch 0 taken 2322 times.
✗ Branch 1 not taken.
2322 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f,true))
4258 {
4259 return qe_invalid;
4260 }
4261 2322 }
4262 387 }
4263
4264 //up bomb rubble
4265
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 43 times.
129 for(int32_t j=0; j<2; j++)
4266 {
4267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f,true))
4268 {
4269 return qe_invalid;
4270 }
4271 86 }
4272
4273
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 43 times.
129 for(int32_t j=0; j<2; j++)
4274 {
4275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f,true))
4276 {
4277 return qe_invalid;
4278 }
4279 86 }
4280
4281 //down bomb rubble
4282
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 43 times.
129 for(int32_t j=0; j<2; j++)
4283 {
4284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f,true))
4285 {
4286 return qe_invalid;
4287 }
4288 86 }
4289
4290
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 43 times.
129 for(int32_t j=0; j<2; j++)
4291 {
4292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f,true))
4293 {
4294 return qe_invalid;
4295 }
4296 86 }
4297
4298 //left bomb rubble
4299
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 43 times.
172 for(int32_t j=0; j<3; j++)
4300 {
4301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f,true))
4302 {
4303 return qe_invalid;
4304 }
4305 129 }
4306
4307
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 43 times.
172 for(int32_t j=0; j<3; j++)
4308 {
4309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f,true))
4310 {
4311 return qe_invalid;
4312 }
4313 129 }
4314
4315
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 if(Header->zelda_version < 0x193)
4316 {
4317 if(!p_getc(&padding,f,true))
4318 {
4319 return qe_invalid;
4320 }
4321
4322 }
4323
4324 //right bomb rubble
4325
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 43 times.
172 for(int32_t j=0; j<3; j++)
4326 {
4327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f,true))
4328 {
4329 return qe_invalid;
4330 }
4331 129 }
4332
4333
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 43 times.
172 for(int32_t j=0; j<3; j++)
4334 {
4335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f,true))
4336 {
4337 return qe_invalid;
4338 }
4339 129 }
4340
4341
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 if(Header->zelda_version < 0x193)
4342 {
4343 if(!p_getc(&padding,f,true))
4344 {
4345 return qe_invalid;
4346 }
4347 }
4348
4349 //walkthrough stuff
4350
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 43 times.
215 for(int32_t j=0; j<4; j++)
4351 {
4352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 172 times.
172 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f,true))
4353 {
4354 return qe_invalid;
4355 }
4356 172 }
4357
4358
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 43 times.
215 for(int32_t j=0; j<4; j++)
4359 {
4360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 172 times.
172 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f,true))
4361 {
4362 return qe_invalid;
4363 }
4364 172 }
4365
4366 //flags
4367
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 43 times.
129 for(int32_t j=0; j<2; j++)
4368 {
4369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(!p_getc(&tempDoorComboSet.flags[j],f,true))
4370 {
4371 return qe_invalid;
4372 }
4373 86 }
4374
4375
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 if(Header->zelda_version < 0x193)
4376 {
4377 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f,true))
4378 {
4379 return qe_invalid;
4380 }
4381 }
4382
4383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(keepdata==true)
4384 {
4385 43 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4386 43 }
4387 43 }
4388
4389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata==true)
4390 {
4391 13 door_combo_set_count=temp_door_combo_set_count;
4392 13 }
4393
4394 13 return 0;
4395 13 }
4396
4397 int32_t count_dmaps()
4398 {
4399 int32_t i=MAXDMAPS-1;
4400 bool found=false;
4401
4402 while(i>=0 && !found)
4403 {
4404 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4405 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4406 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4407 found=true;
4408
4409 for(int32_t j=0; j<8; j++)
4410 {
4411 if(DMaps[i].grid[j]!=0)
4412
4413 found=true;
4414 }
4415
4416 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4417 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4418 found=true;
4419
4420 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4421 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4422 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4423 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4424 found=true;
4425
4426 if(!found)
4427 {
4428 i--;
4429 }
4430 }
4431
4432 return i+1;
4433 }
4434
4435
4436 int32_t count_shops(miscQdata *Misc)
4437 {
4438 int32_t i=255,j;
4439 bool found=false;
4440
4441 while(i>=0 && !found)
4442 {
4443 j=2;
4444
4445 while(j>=0 && !found)
4446 {
4447 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4448 {
4449 found=true;
4450 }
4451 else
4452 {
4453 j--;
4454 }
4455 }
4456
4457 if(Misc->shop[i].name[0]!=0)
4458 {
4459 found=true;
4460 }
4461
4462 if(!found)
4463 {
4464 i--;
4465 }
4466 }
4467
4468 return i+1;
4469 }
4470
4471 int32_t count_infos(miscQdata *Misc)
4472 {
4473 int32_t i=255,j;
4474 bool found=false;
4475
4476 while(i>=0 && !found)
4477 {
4478 j=2;
4479
4480 while(j>=0 && !found)
4481 {
4482 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4483 {
4484 found=true;
4485 }
4486 else
4487 {
4488 j--;
4489 }
4490 }
4491
4492 if(Misc->info[i].name[0]!=0)
4493 {
4494 found=true;
4495 }
4496
4497 if(!found)
4498 {
4499 i--;
4500 }
4501 }
4502
4503 return i+1;
4504 }
4505
4506 int32_t count_warprings(miscQdata *Misc)
4507 {
4508 int32_t i=15,j;
4509 bool found=false;
4510
4511 while(i>=0 && !found)
4512 {
4513 j=7;
4514
4515 while(j>=0 && !found)
4516 {
4517 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4518 {
4519 found=true;
4520 }
4521 else
4522 {
4523 j--;
4524 }
4525 }
4526
4527 if(!found)
4528 {
4529 i--;
4530 }
4531 }
4532
4533 return i+1;
4534 }
4535
4536 int32_t count_palcycles(miscQdata *Misc)
4537 {
4538 int32_t i=255,j;
4539 bool found=false;
4540
4541 while(i>=0 && !found)
4542 {
4543 j=2;
4544
4545 while(j>=0 && !found)
4546 {
4547 if(Misc->cycles[i][j].count!=0)
4548 {
4549 found=true;
4550 }
4551 else
4552 {
4553 j--;
4554 }
4555 }
4556
4557 if(!found)
4558 {
4559 i--;
4560 }
4561 }
4562
4563 return i+1;
4564 }
4565
4566 9397 void clear_screen(mapscr *temp_scr)
4567 {
4568 9397 temp_scr->zero_memory();
4569 9397 }
4570
4571 13 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps, bool keepdata)
4572 {
4573 13 word dmapstoread=0;
4574 dmap tempDMap;
4575
4576 int32_t dummy;
4577 13 word s_version=0, s_cversion=0;
4578 byte padding;
4579
4580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata==true)
4581 {
4582
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 13 times.
6669 for(int32_t i=0; i<max_dmaps; i++)
4583 {
4584 6656 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4585 6656 sprintf(DMaps[start_dmap+i].title," ");
4586 6656 sprintf(DMaps[start_dmap+i].intro," ");
4587 6656 DMaps[start_dmap+i].type |= dmCAVE;
4588 6656 }
4589 13 }
4590
4591
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!Header || Header->zelda_version > 0x192)
4592 {
4593 //section version info
4594
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_version,f,true))
4595 {
4596 return qe_invalid;
4597 }
4598
4599 13 FFCore.quest_format[vDMaps] = s_version;
4600
4601 //al_trace("DMaps version %d\n", s_version);
4602
4603
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_cversion,f,true))
4604 {
4605 return qe_invalid;
4606 }
4607
4608 //section size
4609
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy,f,true))
4610 {
4611 return qe_invalid;
4612 }
4613
4614 //finally... section data
4615
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&dmapstoread,f,true))
4616 {
4617 return qe_invalid;
4618 }
4619 13 }
4620 else
4621 {
4622 if((Header->zelda_version < 0x192)||
4623 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4624 {
4625 dmapstoread=32;
4626 }
4627 else if(s_version <= 4)
4628 {
4629 dmapstoread=OLDMAXDMAPS;
4630 }
4631 else
4632 {
4633 dmapstoread=MAXDMAPS;
4634 }
4635 }
4636
4637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 dmapstoread=zc_min(dmapstoread, max_dmaps);
4638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4639
4640
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 13 times.
6669 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4641 {
4642 6656 memset(&tempDMap,0,sizeof(dmap));
4643 6656 sprintf(tempDMap.title," ");
4644 6656 sprintf(tempDMap.intro," ");
4645
4646
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&tempDMap.map,f,keepdata))
4647 {
4648 return qe_invalid;
4649 }
4650
4651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
6656 if(s_version <= 4)
4652 {
4653 byte tempbyte;
4654
4655 if(!p_getc(&tempbyte,f,keepdata))
4656 {
4657 return qe_invalid;
4658 }
4659
4660 tempDMap.level=(word)tempbyte;
4661 }
4662 else
4663 {
4664
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&tempDMap.level,f,keepdata))
4665 {
4666 return qe_invalid;
4667 }
4668 }
4669
4670
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&tempDMap.xoff,f,keepdata))
4671 {
4672 return qe_invalid;
4673 }
4674
4675
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&tempDMap.compass,f,keepdata))
4676 {
4677 return qe_invalid;
4678 }
4679
4680
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(s_version > 8) // February 2009
4681 {
4682
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&tempDMap.color,f,true))
4683 {
4684 return qe_invalid;
4685 }
4686 6656 }
4687 else
4688 {
4689 byte tempbyte;
4690
4691 if(!p_getc(&tempbyte,f,true))
4692 {
4693 return qe_invalid;
4694 }
4695
4696 tempDMap.color = (word)tempbyte;
4697 }
4698
4699
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&tempDMap.midi,f,keepdata))
4700 {
4701 return qe_invalid;
4702 }
4703
4704
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&tempDMap.cont,f,keepdata))
4705 {
4706 return qe_invalid;
4707 }
4708
4709
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&tempDMap.type,f,keepdata))
4710 {
4711 return qe_invalid;
4712 }
4713
4714
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 6633 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
6679 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4715
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4716 23 tempDMap.xoff = 0;
4717
4718
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 6656 times.
59904 for(int32_t j=0; j<8; j++)
4719 {
4720
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_getc(&tempDMap.grid[j],f,keepdata))
4721 {
4722 return qe_invalid;
4723 }
4724 53248 }
4725
4726
3/8
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6656 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6656 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6656 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4727 {
4728 if(tempDMap.level>0&&tempDMap.level<10)
4729 {
4730 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4731 }
4732
4733 if(i==0 && Header->zelda_version <= 0x190)
4734 {
4735 tempDMap.cont-=tempDMap.xoff;
4736 tempDMap.compass-=tempDMap.xoff;
4737 }
4738
4739 //forgotten -DD
4740 if(tempDMap.level==0)
4741 {
4742 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4743 }
4744 }
4745 else
4746 {
4747
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f,true))
4748 {
4749 return qe_invalid;
4750 }
4751
4752
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f,true))
4753 {
4754 return qe_invalid;
4755 }
4756
4757
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f,true))
4758 {
4759 return qe_invalid;
4760 }
4761
4762
3/8
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6656 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6656 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6656 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4763 {
4764 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4765 if(keepdata==true)
4766 {
4767 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4768 }
4769
4770 continue;
4771 }
4772
4773
2/4
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6656 times.
✗ Branch 3 not taken.
6656 if(Header && (Header->zelda_version < 0x193))
4774 {
4775 if(!p_getc(&padding,f,keepdata))
4776 {
4777 return qe_invalid;
4778 }
4779 }
4780
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if ( s_version >= 11 )
4781 {
4782
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&tempDMap.minimap_1_tile,f,keepdata))
4783 {
4784 return qe_invalid;
4785 }
4786 1024 }
4787 else
4788 {
4789
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempDMap.minimap_1_tile,f,keepdata))
4790 {
4791 return qe_invalid;
4792 }
4793 }
4794
4795
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&tempDMap.minimap_1_cset,f,keepdata))
4796 {
4797 return qe_invalid;
4798 }
4799
4800
2/4
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6656 times.
✗ Branch 3 not taken.
6656 if(Header && (Header->zelda_version < 0x193))
4801 {
4802 if(!p_getc(&padding,f,keepdata))
4803 {
4804 return qe_invalid;
4805 }
4806 }
4807
4808
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if ( s_version >= 11 )
4809 {
4810
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&tempDMap.minimap_2_tile,f,keepdata))
4811 {
4812 return qe_invalid;
4813 }
4814 1024 }
4815 else
4816 {
4817
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempDMap.minimap_2_tile,f,keepdata))
4818 {
4819 return qe_invalid;
4820 }
4821 }
4822
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&tempDMap.minimap_2_cset,f,keepdata))
4823 {
4824 return qe_invalid;
4825 }
4826
4827
2/4
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6656 times.
✗ Branch 3 not taken.
6656 if(Header && (Header->zelda_version < 0x193))
4828 {
4829 if(!p_getc(&padding,f,keepdata))
4830 {
4831 return qe_invalid;
4832 }
4833 }
4834
4835
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if ( s_version >= 11 )
4836 {
4837
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&tempDMap.largemap_1_tile,f,keepdata))
4838 {
4839 return qe_invalid;
4840 }
4841 1024 }
4842 else
4843 {
4844
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempDMap.largemap_1_tile,f,keepdata))
4845 {
4846 return qe_invalid;
4847 }
4848 }
4849
4850
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&tempDMap.largemap_1_cset,f,keepdata))
4851 {
4852 return qe_invalid;
4853 }
4854
4855
2/4
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6656 times.
✗ Branch 3 not taken.
6656 if(Header && (Header->zelda_version < 0x193))
4856 {
4857
4858 if(!p_getc(&padding,f,keepdata))
4859 {
4860 return qe_invalid;
4861 }
4862 }
4863
4864
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if ( s_version >= 11 )
4865 {
4866
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&tempDMap.largemap_2_tile,f,keepdata))
4867 {
4868 return qe_invalid;
4869 }
4870 1024 }
4871 else
4872 {
4873
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&tempDMap.largemap_2_tile,f,keepdata))
4874 {
4875 return qe_invalid;
4876 }
4877 }
4878
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&tempDMap.largemap_2_cset,f,keepdata))
4879 {
4880 return qe_invalid;
4881 }
4882
4883
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f,true))
4884 {
4885 return qe_invalid;
4886 }
4887 }
4888
4889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
6656 if(s_version>1)
4890 {
4891
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&tempDMap.tmusictrack,f,keepdata))
4892 {
4893 return qe_invalid;
4894 }
4895
4896
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&tempDMap.active_subscreen,f,keepdata))
4897 {
4898 return qe_invalid;
4899 }
4900
4901
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&tempDMap.passive_subscreen,f,keepdata))
4902 {
4903 return qe_invalid;
4904 }
4905 6656 }
4906
4907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
6656 if(s_version>2)
4908 {
4909 byte di[32];
4910
4911
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!pfread(&di, 32, f, true)) return qe_invalid;
4912
4913
2/2
✓ Branch 0 taken 1703936 times.
✓ Branch 1 taken 6656 times.
1710592 for(int32_t j=0; j<MAXITEMS; j++)
4914 {
4915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1703936 times.
1703936 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4916 1703936 else tempDMap.disableditems[j]=0;
4917 1703936 }
4918 6656 }
4919
4920
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(s_version >= 6)
4921 {
4922
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetl(&tempDMap.flags,f,keepdata))
4923 {
4924 return qe_invalid;
4925 }
4926 6656 }
4927 else if(s_version>3)
4928 {
4929 char temp;
4930
4931 if(!p_getc(&temp,f,keepdata))
4932 {
4933 return qe_invalid;
4934 }
4935
4936 tempDMap.flags = temp;
4937 }
4938 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4939 {
4940 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4941 }
4942 else
4943 tempDMap.flags=0;
4944
4945
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(s_version<7)
4946 {
4947 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4948 tempDMap.flags|= dmfVIEWMAP;
4949 }
4950
4951
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(s_version<8)
4952 {
4953 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4954 {
4955 tempDMap.type &= ~dmDNGN;
4956 tempDMap.type |= dmCAVE;
4957 }
4958 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4959 {
4960 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4961 }
4962 }
4963
4964
3/8
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6656 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 6656 times.
✗ Branch 7 not taken.
6656 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4965 6656 && (Header->zelda_version < 0x193))
4966 {
4967 if(!p_getc(&padding,f,keepdata))
4968 {
4969 return qe_invalid;
4970 }
4971 }
4972
4973
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
6656 if(s_version >= 10)
4974 {
4975
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&tempDMap.sideview,f,keepdata))
4976 {
4977 return qe_invalid;
4978 }
4979 1024 }
4980
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if(s_version < 10) tempDMap.sideview = 0;
4981
4982 //Dmap Scripts
4983
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
6656 if(s_version >= 12)
4984 {
4985
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetw(&tempDMap.script,f,keepdata))
4986 {
4987 return qe_invalid;
4988 }
4989
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 1024 times.
9216 for ( int32_t q = 0; q < 8; q++ )
4990 {
4991
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(!p_igetl(&tempDMap.initD[q],f,keepdata))
4992 {
4993 return qe_invalid;
4994 }
4995 8192 }
4996 1024 }
4997
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if ( s_version < 12 )
4998 {
4999 5632 tempDMap.script = 0;
5000
2/2
✓ Branch 0 taken 45056 times.
✓ Branch 1 taken 5632 times.
50688 for ( int32_t q = 0; q < 8; q++ )
5001 {
5002 45056 tempDMap.initD[q] = 0;
5003 45056 }
5004 5632 }
5005
5006
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
6656 if(s_version >= 13)
5007 {
5008
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 1024 times.
9216 for ( int32_t q = 0; q < 8; q++ )
5009 {
5010
2/2
✓ Branch 0 taken 532480 times.
✓ Branch 1 taken 8192 times.
540672 for ( int32_t w = 0; w < 65; w++ )
5011 {
5012
1/2
✓ Branch 0 taken 532480 times.
✗ Branch 1 not taken.
532480 if(!p_getc(&tempDMap.initD_label[q][w],f,keepdata))
5013 {
5014 return qe_invalid;
5015 }
5016 532480 }
5017 8192 }
5018 1024 }
5019
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if ( s_version < 13 )
5020 {
5021 5632 tempDMap.script = 0;
5022
2/2
✓ Branch 0 taken 45056 times.
✓ Branch 1 taken 5632 times.
50688 for ( int32_t q = 0; q < 8; q++ )
5023 {
5024
2/2
✓ Branch 0 taken 2928640 times.
✓ Branch 1 taken 45056 times.
2973696 for ( int32_t w = 0; w < 65; w++ )
5025 2928640 tempDMap.initD_label[q][w] = 0;
5026 45056 }
5027 5632 }
5028
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if(s_version >= 14)
5029 {
5030
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetw(&tempDMap.active_sub_script,f,keepdata))
5031 {
5032 return qe_invalid;
5033 }
5034
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetw(&tempDMap.passive_sub_script,f,keepdata))
5035 {
5036 return qe_invalid;
5037 }
5038
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 1024 times.
9216 for ( int32_t q = 0; q < 8; ++q )
5039 {
5040
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(!p_igetl(&tempDMap.sub_initD[q],f,keepdata))
5041 {
5042 return qe_invalid;
5043 }
5044 8192 }
5045
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 1024 times.
9216 for(int32_t q = 0; q < 8; ++q)
5046 {
5047
2/2
✓ Branch 0 taken 532480 times.
✓ Branch 1 taken 8192 times.
540672 for ( int32_t w = 0; w < 65; ++w )
5048 {
5049
1/2
✓ Branch 0 taken 532480 times.
✗ Branch 1 not taken.
532480 if(!p_getc(&tempDMap.sub_initD_label[q][w],f,keepdata))
5050 {
5051 return qe_invalid;
5052 }
5053 532480 }
5054 8192 }
5055 1024 }
5056 else
5057 {
5058 5632 tempDMap.active_sub_script = 0;
5059 5632 tempDMap.passive_sub_script = 0;
5060
2/2
✓ Branch 0 taken 45056 times.
✓ Branch 1 taken 5632 times.
50688 for(int32_t q = 0; q < 8; ++q)
5061 {
5062 45056 tempDMap.sub_initD[q] = 0;
5063
2/2
✓ Branch 0 taken 2928640 times.
✓ Branch 1 taken 45056 times.
2973696 for(int32_t w = 0; w < 65; ++w)
5064 2928640 tempDMap.sub_initD_label[q][w] = 0;
5065 45056 }
5066 }
5067
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if(s_version >= 15)
5068 {
5069
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetw(&tempDMap.onmap_script,f,keepdata))
5070 {
5071 return qe_invalid;
5072 }
5073
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 1024 times.
9216 for ( int32_t q = 0; q < 8; ++q )
5074 {
5075
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(!p_igetl(&tempDMap.onmap_initD[q],f,keepdata))
5076 {
5077 return qe_invalid;
5078 }
5079 8192 }
5080
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 1024 times.
9216 for(int32_t q = 0; q < 8; ++q)
5081 {
5082
2/2
✓ Branch 0 taken 532480 times.
✓ Branch 1 taken 8192 times.
540672 for ( int32_t w = 0; w < 65; ++w )
5083 {
5084
1/2
✓ Branch 0 taken 532480 times.
✗ Branch 1 not taken.
532480 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f,keepdata))
5085 {
5086 return qe_invalid;
5087 }
5088 532480 }
5089 8192 }
5090 1024 }
5091 else
5092 {
5093 5632 tempDMap.onmap_script = 0;
5094
2/2
✓ Branch 0 taken 45056 times.
✓ Branch 1 taken 5632 times.
50688 for(int32_t q = 0; q < 8; ++q)
5095 {
5096 45056 tempDMap.onmap_initD[q] = 0;
5097
2/2
✓ Branch 0 taken 2928640 times.
✓ Branch 1 taken 45056 times.
2973696 for(int32_t w = 0; w < 65; ++w)
5098 {
5099 2928640 tempDMap.onmap_initD_label[q][w] = 0;
5100 2928640 }
5101 45056 }
5102 }
5103
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if(s_version >= 16)
5104 {
5105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(!p_igetw(&tempDMap.mirrorDMap,f,keepdata))
5106 {
5107 return qe_invalid;
5108 }
5109 1024 }
5110 else
5111 {
5112 5632 tempDMap.mirrorDMap = -1;
5113 }
5114
5115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
6656 if(keepdata==true)
5116 {
5117 6656 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5118 6656 }
5119 6656 }
5120
5121 13 return 0;
5122 13 }
5123
5124 13 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5125 {
5126 //these are here to bypass compiler warnings about unused arguments
5127 13 Header=Header;
5128
5129 miscQdata temp_misc;
5130 13 word s_version=0, s_cversion=0;
5131 13 int32_t tempsize=0;
5132 word dummyw;
5133
5134 13 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5135
5136 //section version info
5137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!p_igetw(&s_version,f,true))
5138 {
5139 return qe_invalid;
5140 }
5141
5142 13 FFCore.quest_format[vColours] = s_version;
5143
5144 13 al_trace("Misc Colours section version: %d\n", s_version);
5145
5146 //al_trace("Misc. colors version %d\n", s_version);
5147
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_cversion,f,true))
5148 {
5149 return qe_invalid;
5150 }
5151
5152
5153 //section size
5154
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&tempsize,f,true))
5155 {
5156 return qe_invalid;
5157 }
5158
5159 //finally... section data
5160 13 readsize=0;
5161
5162
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.text,f,true))
5163 {
5164 return qe_invalid;
5165 }
5166
5167
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.caption,f,true))
5168 {
5169 return qe_invalid;
5170 }
5171
5172
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5173 {
5174 return qe_invalid;
5175 }
5176
5177
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5178 {
5179 return qe_invalid;
5180 }
5181
5182
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5183 {
5184 return qe_invalid;
5185 }
5186
5187
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5188 {
5189 return qe_invalid;
5190 }
5191
5192
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5193 {
5194 return qe_invalid;
5195 }
5196
5197
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5198 {
5199 return qe_invalid;
5200 }
5201
5202
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5203 {
5204 return qe_invalid;
5205 }
5206
5207
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5208 {
5209 return qe_invalid;
5210 }
5211
5212
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5213 {
5214 return qe_invalid;
5215 }
5216
5217
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5218 {
5219 return qe_invalid;
5220 }
5221
5222
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5223 {
5224 return qe_invalid;
5225 }
5226
5227
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5228 {
5229 return qe_invalid;
5230 }
5231
5232
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5233 {
5234 return qe_invalid;
5235 }
5236
5237
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5238 {
5239 return qe_invalid;
5240 }
5241
5242
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5243 {
5244 return qe_invalid;
5245 }
5246
5247
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5248 {
5249 return qe_invalid;
5250 }
5251
5252
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5253 {
5254 return qe_invalid;
5255 }
5256
5257
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5258 {
5259 return qe_invalid;
5260 }
5261
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version < 4)
5262 {
5263
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetw(&dummyw,f,true))
5264 return qe_invalid;
5265 11 temp_misc.colors.triforce_tile = dummyw;
5266
5267
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetw(&dummyw,f,true))
5268 return qe_invalid;
5269 11 temp_misc.colors.triframe_tile = dummyw;
5270
5271
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetw(&dummyw,f,true))
5272 return qe_invalid;
5273 11 temp_misc.colors.overworld_map_tile = dummyw;
5274
5275
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetw(&dummyw,f,true))
5276 return qe_invalid;
5277 11 temp_misc.colors.dungeon_map_tile = dummyw;
5278
5279
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetw(&dummyw,f,true))
5280 return qe_invalid;
5281 11 temp_misc.colors.blueframe_tile = dummyw;
5282
5283
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetw(&dummyw,f,true))
5284 return qe_invalid;
5285 11 temp_misc.colors.HCpieces_tile = dummyw;
5286 11 }
5287
5288
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5289 {
5290 return qe_invalid;
5291 }
5292
5293
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5294 {
5295 return qe_invalid;
5296 }
5297
5298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version < 2)
5299 {
5300 temp_misc.colors.msgtext = 0x01;
5301 }
5302 else
5303 {
5304
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&temp_misc.colors.msgtext, f, true))
5305 {
5306 return qe_invalid;
5307 }
5308 }
5309
5310
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if ( s_version >= 3 ) //expanded tile pages to 825
5311 {
5312
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetl(&temp_misc.colors.triforce_tile,f,true))
5313 {
5314 return qe_invalid;
5315 }
5316
5317
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetl(&temp_misc.colors.triframe_tile,f,true))
5318 {
5319 return qe_invalid;
5320 }
5321
5322
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f,true))
5323 {
5324 return qe_invalid;
5325 }
5326
5327
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f,true))
5328 {
5329 return qe_invalid;
5330 }
5331
5332
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetl(&temp_misc.colors.blueframe_tile,f,true))
5333 {
5334 return qe_invalid;
5335 }
5336
5337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f,true))
5338 {
5339 return qe_invalid;
5340 }
5341 2 }
5342
5343
5344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata==true)
5345 {
5346 13 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5347 13 }
5348
5349 13 return 0;
5350 13 }
5351
5352 13 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc, bool keepdata)
5353 {
5354 miscQdata temp_misc;
5355 13 word s_version=0, s_cversion=0;
5356 byte icons;
5357 13 int32_t tempsize=0;
5358
5359 13 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5360
5361 //section version info
5362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!p_igetw(&s_version,f,true))
5363 {
5364 return qe_invalid;
5365 }
5366
5367 13 FFCore.quest_format[vIcons] = s_version;
5368
5369 //al_trace("Game icons version %d\n", s_version);
5370
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_cversion,f,true))
5371 {
5372 return qe_invalid;
5373 }
5374
5375
5376 //section size
5377
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&tempsize,f,true))
5378 {
5379 return qe_invalid;
5380 }
5381
5382 //finally... section data
5383 13 readsize=0;
5384
5385 13 icons=4;
5386
5387
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if ( s_version >= 10 )
5388 {
5389
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t i=0; i<icons; i++)
5390 {
5391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_igetl(&temp_misc.icons[i],f,true))
5392 {
5393 return qe_invalid;
5394 }
5395 8 }
5396 2 }
5397 else
5398 {
5399
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<icons; i++)
5400 {
5401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(!p_igetw(&temp_misc.icons[i],f,true))
5402 {
5403 return qe_invalid;
5404 }
5405 44 }
5406 }
5407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata==true)
5408 {
5409 13 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5410 13 }
5411
5412 13 return 0;
5413 13 }
5414
5415 13 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5416 {
5417 13 word maxinfos=256;
5418 13 word maxshops=256;
5419 13 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5420 13 word ponds=16, pondsize=72, expansionsize=98*2;
5421 byte tempbyte, padding;
5422 miscQdata temp_misc;
5423 13 word s_version=0, s_cversion=0;
5424 word swaptmp;
5425 13 int32_t tempsize=0;
5426
5427 13 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5428
5429
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<maxshops; ++i)
5430 {
5431 3328 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5432 3328 }
5433
5434
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<maxinfos; ++i)
5435 {
5436 3328 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5437 3328 }
5438
5439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(Header->zelda_version > 0x192)
5440 {
5441 //section version info
5442
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_version,f,true))
5443 {
5444 return qe_invalid;
5445 }
5446
5447 13 FFCore.quest_format[vMisc] = s_version;
5448
5449 //al_trace("Misc. data version %d\n", s_version);
5450
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_cversion,f,true))
5451 {
5452 return qe_invalid;
5453 }
5454
5455
5456 //section size
5457
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&tempsize,f,true))
5458 {
5459 return qe_invalid;
5460 }
5461 13 }
5462
5463 //finally... section data
5464 13 readsize=0;
5465
5466 //shops
5467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(Header->zelda_version > 0x192)
5468 {
5469
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&shops,f,true))
5470 {
5471 return qe_invalid;
5472 }
5473 13 }
5474
5475
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 13 times.
184 for(int32_t i=0; i<shops; i++)
5476 {
5477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 171 times.
171 if(s_version > 6)
5478 {
5479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 171 times.
171 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f,true))
5480 {
5481 return qe_invalid;
5482 }
5483 171 }
5484
5485
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 171 times.
684 for(int32_t j=0; j<3; j++)
5486 {
5487
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(!p_getc(&temp_misc.shop[i].item[j],f,true))
5488 {
5489 return qe_invalid;
5490 }
5491
5492
1/2
✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
513 if(s_version < 4)
5493 {
5494 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5495 }
5496 513 }
5497
5498
1/2
✓ Branch 0 taken 171 times.
✗ Branch 1 not taken.
171 if(Header->zelda_version < 0x193)
5499 {
5500 if(!p_getc(&tempbyte,f,true))
5501 {
5502 return qe_invalid;
5503 }
5504 }
5505
5506
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 171 times.
684 for(int32_t j=0; j<3; j++)
5507 {
5508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 513 times.
513 if(!p_igetw(&temp_misc.shop[i].price[j],f,true))
5509 {
5510 return qe_invalid;
5511 }
5512 513 }
5513
5514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 171 times.
171 if(s_version > 3)
5515 {
5516
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 171 times.
684 for(int32_t j=0; j<3; j++)
5517 {
5518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 513 times.
513 if(!p_getc(&temp_misc.shop[i].hasitem[j],f,true))
5519 return qe_invalid;
5520 513 }
5521 171 }
5522
5523 /*
5524 if(s_version < 8)
5525 {
5526 for(int32_t j=0; j<3; j++)
5527 {
5528 (&temp_misc.shop[i].str[j])=0; //initialise.
5529 }
5530 }
5531 */
5532 171 }
5533
5534 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5535
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<maxshops; ++i)
5536 {
5537
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 3328 times.
9984 for(int32_t j=0; j<3-1; j++)
5538 {
5539
2/2
✓ Branch 0 taken 9984 times.
✓ Branch 1 taken 6656 times.
16640 for(int32_t k=0; k<2-j; k++)
5540 {
5541
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 9585 times.
9984 if(temp_misc.shop[i].hasitem[k]==0)
5542 {
5543 9585 swaptmp = temp_misc.shop[i].item[k];
5544 9585 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5545 9585 temp_misc.shop[i].item[k+1] = swaptmp;
5546 9585 swaptmp = temp_misc.shop[i].price[k];
5547 9585 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5548 9585 temp_misc.shop[i].price[k+1] = swaptmp;
5549 9585 swaptmp = temp_misc.shop[i].hasitem[k];
5550 9585 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5551 9585 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5552 9585 }
5553 9984 }
5554 6656 }
5555 3328 }
5556
5557 //infos
5558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(Header->zelda_version > 0x192)
5559 {
5560
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&infos,f,true))
5561 {
5562 return qe_invalid;
5563 }
5564 13 }
5565
5566
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 13 times.
205 for(int32_t i=0; i<infos; i++)
5567 {
5568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(s_version > 6)
5569 {
5570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f,true))
5571 {
5572 return qe_invalid;
5573 }
5574 192 }
5575
5576
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 192 times.
768 for(int32_t j=0; j<3; j++)
5577 {
5578
1/4
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
576 if((Header->zelda_version < 0x192)||
5579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
576 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5580 {
5581 if(!p_getc(&tempbyte,f,true))
5582 {
5583 return qe_invalid;
5584 }
5585
5586 temp_misc.info[i].str[j]=tempbyte;
5587 }
5588 else
5589 {
5590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
576 if(!p_igetw(&temp_misc.info[i].str[j],f,true))
5591 {
5592 return qe_invalid;
5593 }
5594 }
5595 576 }
5596
5597
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(Header->zelda_version < 0x193)
5598 {
5599 if(!p_getc(&tempbyte,f,true))
5600 {
5601 return qe_invalid;
5602 }
5603 }
5604
5605
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
192 if((Header->zelda_version == 0x192)&&(Header->build>145))
5606 {
5607 if(!p_getc(&padding,f,true))
5608 {
5609 return qe_invalid;
5610 }
5611 }
5612
5613
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 192 times.
768 for(int32_t j=0; j<3; j++)
5614 {
5615
1/2
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
576 if(!p_igetw(&temp_misc.info[i].price[j],f,true))
5616 {
5617 return qe_invalid;
5618 }
5619 576 }
5620 192 }
5621
5622 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5623
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<maxinfos; ++i)
5624 {
5625
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 3328 times.
9984 for(int32_t j=0; j<3-1; j++)
5626 {
5627
2/2
✓ Branch 0 taken 9984 times.
✓ Branch 1 taken 6656 times.
16640 for(int32_t k=0; k<2-j; k++)
5628 {
5629
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 9762 times.
9984 if(temp_misc.info[i].str[k]==0)
5630 {
5631 9762 swaptmp = temp_misc.info[i].str[k];
5632 9762 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5633 9762 temp_misc.info[i].str[k+1] = swaptmp;
5634 9762 swaptmp = temp_misc.info[i].price[k];
5635 9762 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5636 9762 temp_misc.info[i].price[k+1] = swaptmp;
5637 9762 }
5638 9984 }
5639 6656 }
5640 3328 }
5641
5642
5643 //warp rings
5644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version > 5)
5645 13 warprings++;
5646
5647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(Header->zelda_version > 0x192)
5648 {
5649
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&warprings,f,true))
5650 {
5651 return qe_invalid;
5652 }
5653 13 }
5654
5655
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 13 times.
146 for(int32_t i=0; i<warprings; i++)
5656 {
5657
2/2
✓ Branch 0 taken 1197 times.
✓ Branch 1 taken 133 times.
1330 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5658 {
5659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1197 times.
1197 if(s_version <= 3)
5660 {
5661 if(!p_getc(&tempbyte,f,true))
5662 {
5663 return qe_invalid;
5664 }
5665
5666 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5667 }
5668 else
5669 {
5670
1/2
✓ Branch 0 taken 1197 times.
✗ Branch 1 not taken.
1197 if(!p_igetw(&temp_misc.warp[i].dmap[j],f,true))
5671 {
5672 return qe_invalid;
5673 }
5674 }
5675 1197 }
5676
5677
2/2
✓ Branch 0 taken 1197 times.
✓ Branch 1 taken 133 times.
1330 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5678 {
5679
1/2
✓ Branch 0 taken 1197 times.
✗ Branch 1 not taken.
1197 if(!p_getc(&temp_misc.warp[i].scr[j],f,true))
5680 {
5681 return qe_invalid;
5682 }
5683 1197 }
5684
5685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 if(!p_getc(&temp_misc.warp[i].size,f,true))
5686 {
5687 return qe_invalid;
5688 }
5689
5690
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(Header->zelda_version < 0x193)
5691 {
5692 if(!p_getc(&tempbyte,f,true))
5693 {
5694 return qe_invalid;
5695 }
5696 }
5697 133 }
5698
5699 //palette cycles
5700
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5701 {
5702 for(int32_t i=0; i<256; i++)
5703 {
5704 for(int32_t j=0; j<3; j++)
5705 {
5706 temp_misc.cycles[i][j].first=0;
5707 temp_misc.cycles[i][j].count=0;
5708 temp_misc.cycles[i][j].speed=0;
5709 }
5710 }
5711
5712 if((Header->zelda_version < 0x192)||
5713 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5714 {
5715 palcycles=16;
5716 }
5717
5718 for(int32_t i=0; i<palcycles; i++)
5719 {
5720 for(int32_t j=0; j<3; j++)
5721 {
5722 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
5723 {
5724 return qe_invalid;
5725 }
5726
5727 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
5728 {
5729 return qe_invalid;
5730 }
5731
5732 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
5733 {
5734 return qe_invalid;
5735 }
5736 }
5737 }
5738 }
5739
5740 //Wind warps are now just another warp ring.
5741
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version <= 5)
5742 {
5743 if(Header->zelda_version > 0x192)
5744 {
5745 if(!p_igetw(&windwarps,f,true))
5746 {
5747 return qe_invalid;
5748 }
5749 }
5750
5751 for(int32_t i=0; i<windwarps; i++)
5752 {
5753 if(s_version <= 3)
5754 {
5755 if(!p_getc(&tempbyte,f,true))
5756 {
5757 return qe_invalid;
5758 }
5759
5760 temp_misc.warp[8].dmap[i]=tempbyte;
5761 }
5762 else
5763 {
5764 if(!p_igetw(&temp_misc.warp[8].dmap[i],f,true))
5765 {
5766 return qe_invalid;
5767 }
5768 }
5769
5770 if(!p_getc(&temp_misc.warp[8].scr[i],f,true))
5771 {
5772 return qe_invalid;
5773 }
5774
5775 temp_misc.warp[8].size = 9;
5776
5777 if(s_version == 5)
5778 {
5779 if(!p_getc(&tempbyte,f,true))
5780 {
5781 return qe_invalid;
5782 }
5783 }
5784 }
5785 }
5786
5787
5788 //triforce pieces
5789
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 13 times.
117 for(int32_t i=0; i<triforces; i++)
5790 {
5791
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_getc(&temp_misc.triforce[i],f,true))
5792 {
5793 return qe_invalid;
5794 }
5795 104 }
5796
5797 //misc color data
5798
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version<3)
5799 {
5800 if(!p_getc(&temp_misc.colors.text,f,true))
5801 {
5802 return qe_invalid;
5803 }
5804
5805 if(!p_getc(&temp_misc.colors.caption,f,true))
5806 {
5807 return qe_invalid;
5808 }
5809
5810 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5811 {
5812 return qe_invalid;
5813 }
5814
5815 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5816 {
5817 return qe_invalid;
5818 }
5819
5820 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5821 {
5822 return qe_invalid;
5823 }
5824
5825 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5826 {
5827 return qe_invalid;
5828 }
5829
5830 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5831 {
5832 return qe_invalid;
5833 }
5834
5835 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5836 {
5837 return qe_invalid;
5838 }
5839
5840 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5841 {
5842 return qe_invalid;
5843 }
5844
5845 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5846 {
5847 return qe_invalid;
5848 }
5849
5850 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5851 {
5852 return qe_invalid;
5853 }
5854
5855 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5856 {
5857 return qe_invalid;
5858 }
5859
5860 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5861 {
5862 return qe_invalid;
5863 }
5864
5865 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5866 {
5867 return qe_invalid;
5868 }
5869
5870 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5871 {
5872 return qe_invalid;
5873 }
5874
5875 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5876 {
5877 return qe_invalid;
5878 }
5879
5880 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5881 {
5882 return qe_invalid;
5883 }
5884
5885 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5886 {
5887 return qe_invalid;
5888 }
5889
5890 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5891 {
5892 return qe_invalid;
5893 }
5894
5895 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5896 {
5897 return qe_invalid;
5898 }
5899
5900 if(!p_igetw(&temp_misc.colors.triforce_tile,f,true))
5901 {
5902 return qe_invalid;
5903 }
5904
5905 if(!p_igetw(&temp_misc.colors.triframe_tile,f,true))
5906 {
5907 return qe_invalid;
5908 }
5909
5910 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f,true))
5911 {
5912 return qe_invalid;
5913 }
5914
5915 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f,true))
5916 {
5917 return qe_invalid;
5918 }
5919
5920 if(!p_igetw(&temp_misc.colors.blueframe_tile,f,true))
5921 {
5922 return qe_invalid;
5923 }
5924
5925 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f,true))
5926 {
5927 return qe_invalid;
5928 }
5929
5930 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5931 {
5932 return qe_invalid;
5933 }
5934
5935 temp_misc.colors.msgtext = 0x01;
5936
5937 if(Header->zelda_version < 0x193)
5938 {
5939 for(int32_t i=0; i<7; i++)
5940 {
5941 if(!p_getc(&tempbyte,f,true))
5942 {
5943 return qe_invalid;
5944 }
5945 }
5946 }
5947
5948 if((Header->zelda_version == 0x192)&&(Header->build>145))
5949 {
5950 for(int32_t i=0; i<256; i++)
5951 {
5952 if(!p_getc(&tempbyte,f,true))
5953 {
5954 return qe_invalid;
5955 }
5956 }
5957 }
5958
5959 if(s_version>1)
5960 {
5961 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5962 {
5963 return qe_invalid;
5964 }
5965 }
5966
5967 //save game icons
5968 if((Header->zelda_version < 0x192)||
5969 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5970 {
5971 icons=3;
5972 }
5973
5974 for(int32_t i=0; i<icons; i++)
5975 {
5976 if(!p_igetw(&temp_misc.icons[i],f,true))
5977 {
5978 return qe_invalid;
5979 }
5980 }
5981 }
5982
5983
1/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if((Header->zelda_version < 0x192)||
5984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ((Header->zelda_version == 0x192)&&(Header->build<30)))
5985 {
5986 if(keepdata==true)
5987 {
5988 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5989 }
5990
5991 return 0;
5992 }
5993
5994 //pond information
5995
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Header->zelda_version < 0x193)
5996 {
5997 if((Header->zelda_version == 0x192)&&(Header->build<146))
5998 {
5999 pondsize=25;
6000 }
6001
6002 for(int32_t i=0; i<ponds; i++)
6003 {
6004 for(int32_t j=0; j<pondsize; j++)
6005 {
6006 if(!p_getc(&tempbyte,f,true))
6007 {
6008 return qe_invalid;
6009
6010 }
6011 }
6012 }
6013 }
6014
6015 //end string
6016
1/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if((Header->zelda_version < 0x192)||
6017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6018 {
6019 if(!p_getc(&tempbyte,f,true))
6020 {
6021 return qe_invalid;
6022 }
6023
6024 temp_misc.endstring=tempbyte;
6025
6026 if(!p_getc(&tempbyte,f,true))
6027 {
6028 return qe_invalid;
6029 }
6030 }
6031 else
6032 {
6033
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&temp_misc.endstring,f,true))
6034 {
6035 return qe_invalid;
6036 }
6037 }
6038
6039 //expansion
6040
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Header->zelda_version < 0x193)
6041 {
6042 if((Header->zelda_version == 0x192)&&(Header->build<73))
6043 {
6044 expansionsize=99*2;
6045 }
6046
6047 for(int32_t i=0; i<expansionsize; i++)
6048 {
6049 if(!p_getc(&tempbyte,f,true))
6050 {
6051 return qe_invalid;
6052 }
6053 }
6054 }
6055 //shops v8
6056
6057
6058
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(s_version >= 8)
6059 {
6060
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 2 times.
34 for(int32_t i=0; i<shops; i++)
6061 {
6062
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 32 times.
128 for(int32_t j=0; j<3; j++)
6063 {
6064
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_igetw(&temp_misc.shop[i].str[j],f,true))
6065 return qe_invalid;
6066 96 }
6067 32 }
6068 2 }
6069
6070 13 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6071 13 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6072 13 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6073
6074 //v9 includes quest misc[32]
6075
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(s_version >= 9)
6076 {
6077
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 2 times.
66 for ( int32_t q = 0; q < 32; q++ )
6078 {
6079
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_igetl(&temp_misc.questmisc[q],f,true))
6080 return qe_invalid;
6081 64 }
6082
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 2 times.
66 for ( int32_t q = 0; q < 32; q++ )
6083 {
6084
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 64 times.
8256 for ( int32_t j = 0; j < 128; j++ )
6085
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(!p_getc(&temp_misc.questmisc_strings[q][j],f,true))
6086 return qe_invalid;
6087 64 }
6088 2 }
6089
6090
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version >= 11 )
6091 {
6092
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f,true))
6093 return qe_invalid;
6094 2 }
6095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 else if(s_version < 11 )
6096 {
6097 11 temp_misc.zscript_last_compiled_version = -1;
6098 11 }
6099
6100 13 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6101
6102
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version >= 12)
6103 {
6104 byte spr;
6105
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2 times.
514 for(int32_t q = 0; q < sprMAX; ++q)
6106 {
6107
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_getc(&spr,f,true))
6108 return qe_invalid;
6109 512 temp_misc.sprites[q] = spr;
6110 512 }
6111 2 }
6112 else
6113 {
6114 11 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6115 //temp_misc.sprites[sprFALL] = ;
6116 }
6117
6118
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version >= 13)
6119 {
6120
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 2 times.
130 for(size_t q = 0; q < 64; ++q)
6121 {
6122 128 bottletype* bt = &(temp_misc.bottle_types[q]);
6123
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (!pfread(bt->name, 32, f, true))
6124 return qe_invalid;
6125
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 128 times.
512 for(size_t j = 0; j < 3; ++j)
6126 {
6127
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if (!p_getc(&(bt->counter[j]), f, true))
6128 return qe_invalid;
6129
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if (!p_igetw(&(bt->amount[j]), f, true))
6130 return qe_invalid;
6131 384 }
6132
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (!p_getc(&(bt->flags), f, true))
6133 return qe_invalid;
6134
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (!p_getc(&(bt->next_type), f, true))
6135 return qe_invalid;
6136 128 }
6137
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2 times.
514 for(size_t q = 0; q < 256; ++q)
6138 {
6139 512 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6140
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if (!pfread(bst->name, 32, f, true))
6141 return qe_invalid;
6142
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 512 times.
2048 for(size_t j = 0; j < 3; ++j)
6143 {
6144
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if (!p_getc(&(bst->fill[j]), f, true))
6145 return qe_invalid;
6146
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if (!p_igetw(&(bst->comb[j]), f, true))
6147 return qe_invalid;
6148
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if (!p_getc(&(bst->cset[j]), f, true))
6149 return qe_invalid;
6150
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if (!p_igetw(&(bst->price[j]), f, true))
6151 return qe_invalid;
6152
1/2
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
1536 if (!p_igetw(&(bst->str[j]), f, true))
6153 return qe_invalid;
6154 1536 }
6155 512 }
6156 2 }
6157 else
6158 {
6159
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 11 times.
715 for(size_t q = 0; q < 64; ++q)
6160 704 temp_misc.bottle_types[q].clear();
6161
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(size_t q = 0; q < 256; ++q)
6162 2816 temp_misc.bottle_shop_types[q].clear();
6163 }
6164
6165
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version >= 14)
6166 {
6167 byte msfx;
6168
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2 times.
514 for(int32_t q = 0; q < sfxMAX; ++q)
6169 {
6170
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_getc(&msfx,f,true))
6171 return qe_invalid;
6172 512 temp_misc.miscsfx[q] = msfx;
6173 512 }
6174 2 }
6175 else
6176 {
6177 11 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6178 11 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6179 11 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6180 }
6181
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version < 15)
6182 {
6183 11 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6184 11 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6185 11 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6186 11 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6187 11 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6188 11 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6189 11 }
6190
6191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata==true)
6192 {
6193 13 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6194 13 }
6195
6196 13 return 0;
6197 13 }
6198
6199 extern char *item_string[ITEMCNT];
6200 extern const char *old_item_string[iLast];
6201 extern char *weapon_string[WPNCNT];
6202 extern const char *old_weapon_string[wLast];
6203
6204 13 int32_t readitems(PACKFILE *f, word version, word build, bool keepdata, bool zgpmode)
6205 {
6206 byte padding;
6207 int32_t dummy;
6208 13 word items_to_read=MAXITEMS;
6209 itemdata tempitem;
6210 13 word s_version=0, s_cversion=0;
6211 word dummy_word;
6212
6213
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(version < 0x186)
6214 {
6215 items_to_read=64;
6216 }
6217
6218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(version > 0x192)
6219 {
6220 13 items_to_read=0;
6221
6222 //section version info
6223
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_version,f,true))
6224 {
6225 return qe_invalid;
6226 }
6227
6228 13 FFCore.quest_format[vItems] = s_version;
6229
6230 //al_trace("Items version %d\n", s_version);
6231
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_cversion,f,true))
6232 {
6233 return qe_invalid;
6234 }
6235
6236 //section size
6237
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy,f,true))
6238 {
6239 return qe_invalid;
6240 }
6241
6242 //finally... section data
6243
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&items_to_read,f,true))
6244 {
6245 return qe_invalid;
6246 }
6247 13 }
6248
6249
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version>1)
6250 {
6251
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<items_to_read; i++)
6252 {
6253 char tempname[64];
6254
6255
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!pfread(tempname, 64, f, keepdata))
6256 {
6257 return qe_invalid;
6258 }
6259
6260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
3328 if(keepdata)
6261 {
6262 3328 strcpy(item_string[i], tempname);
6263 3328 }
6264 3328 }
6265 13 }
6266 else
6267 {
6268 if(keepdata)
6269 {
6270 for(int32_t i=0; i<ITEMCNT; i++)
6271 {
6272 reset_itemname(i);
6273 }
6274 }
6275 }
6276
6277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata)
6278 {
6279
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<MAXITEMS; i++)
6280 {
6281 3328 itemdata& id = itemsbuf[i];
6282 3328 memset(&id, 0, sizeof(itemdata));
6283 3328 id.count=-1;
6284 3328 id.playsound=WAV_SCALE;
6285 3328 reset_itembuf(&id,i);
6286 3328 }
6287 13 }
6288
6289
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<items_to_read; i++)
6290 {
6291 3328 memset(&tempitem, 0, sizeof(itemdata));
6292 3328 reset_itembuf(&tempitem,i);
6293
6294
6295
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if ( s_version > 35 ) //expanded tiles
6296 {
6297
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.tile,f,true))
6298 {
6299 return qe_invalid;
6300 }
6301 512 }
6302 else
6303 {
6304
1/2
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
2816 if(!p_igetw(&tempitem.tile,f,true))
6305 {
6306 return qe_invalid;
6307 }
6308 }
6309
6310
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.misc_flags,f,true))
6311 {
6312 return qe_invalid;
6313 }
6314
6315
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.csets,f,true))
6316 {
6317 return qe_invalid;
6318 }
6319
6320
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.frames,f,true))
6321 {
6322 return qe_invalid;
6323 }
6324
6325
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.speed,f,true))
6326 {
6327 return qe_invalid;
6328 }
6329
6330
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.delay,f,true))
6331 {
6332 return qe_invalid;
6333 }
6334
6335
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(version < 0x193)
6336 {
6337 if(!p_getc(&padding,f,true))
6338 {
6339 return qe_invalid;
6340 }
6341
6342 if((version < 0x192)||((version == 0x192)&&(build<186)))
6343 {
6344 switch(i)
6345 {
6346 case iShield:
6347 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-12:10;
6348 break;
6349
6350 case iMShield:
6351 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-6:-10;
6352 break;
6353
6354 default:
6355 tempitem.ltm=0;
6356 break;
6357 }
6358
6359 tempitem.count=-1;
6360 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6361 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6362 tempitem.family=0xFF;
6363 tempitem.playsound=WAV_SCALE;
6364 reset_itembuf(&tempitem,i);
6365
6366 if(keepdata==true)
6367 {
6368 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6369 }
6370
6371 continue;
6372 }
6373 }
6374
6375
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_igetl(&tempitem.ltm,f,true))
6376 {
6377 return qe_invalid;
6378 }
6379
6380
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(version < 0x193)
6381 {
6382 for(int32_t q=0; q<12; q++)
6383 {
6384 if(!p_getc(&padding,f,true))
6385 {
6386 return qe_invalid;
6387 }
6388 }
6389 }
6390
6391
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version>1)
6392 {
6393
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if ( s_version >= 31 )
6394 {
6395
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.family,f,true))
6396 {
6397 return qe_invalid;
6398 }
6399 512 }
6400 else
6401 {
6402
1/2
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
2816 if(!p_getc(&tempitem.family,f,true))
6403 {
6404 return qe_invalid;
6405 }
6406 }
6407
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 16)
6408 if(tempitem.family == 0xFF)
6409 tempitem.family = itype_misc;
6410
6411
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.fam_type,f,true))
6412 {
6413 return qe_invalid;
6414 }
6415
6416
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version>5)
6417 {
6418
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if(s_version>=31)
6419 {
6420
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.power,f,true))
6421 {
6422 return qe_invalid;
6423 }
6424 512 }
6425 else
6426 {
6427
1/2
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
2816 if(!p_getc(&tempitem.power,f,true))
6428 {
6429 return qe_invalid;
6430 }
6431 }
6432
6433 //converted flags from 16b to 32b -Z
6434
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 512 times.
3328 if ( s_version < 41 )
6435 {
6436
1/2
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
2816 if(!p_igetw(&tempitem.flags,f,true))
6437 {
6438 return qe_invalid;
6439 }
6440 2816 }
6441 else
6442 {
6443
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.flags,f,true))
6444 {
6445 return qe_invalid;
6446 }
6447 }
6448 3328 }
6449 else
6450 {
6451 //tempitem.power = tempitem.fam_type;
6452 char tempchar;
6453
6454 if(!p_getc(&tempchar,f,true))
6455 {
6456 return qe_invalid;
6457 }
6458
6459 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6460 }
6461
6462
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_igetw(&tempitem.script,f,true))
6463 {
6464 return qe_invalid;
6465 }
6466
6467
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version<=3)
6468 {
6469 if(tempitem.script > NUMSCRIPTITEM)
6470 {
6471 tempitem.script = 0;
6472 }
6473 }
6474
6475
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.count,f,true))
6476 {
6477 return qe_invalid;
6478 }
6479
6480
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_igetw(&tempitem.amount,f,true))
6481 {
6482 return qe_invalid;
6483 }
6484
6485
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_igetw(&tempitem.collect_script,f,true))
6486 {
6487 return qe_invalid;
6488 }
6489
6490
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version<=3)
6491 {
6492 if(tempitem.collect_script > NUMSCRIPTITEM)
6493 {
6494 tempitem.collect_script = 0;
6495 }
6496 }
6497
6498
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_igetw(&tempitem.setmax,f,true))
6499 {
6500 return qe_invalid;
6501 }
6502
6503
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_igetw(&tempitem.max,f,true))
6504 {
6505 return qe_invalid;
6506 }
6507
6508
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.playsound,f,true))
6509 {
6510 return qe_invalid;
6511 }
6512
6513
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 3328 times.
29952 for(int32_t j=0; j<8; j++)
6514 {
6515
1/2
✓ Branch 0 taken 26624 times.
✗ Branch 1 not taken.
26624 if(!p_igetl(&tempitem.initiald[j],f,true))
6516 {
6517 return qe_invalid;
6518 }
6519 26624 }
6520
6521
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 3328 times.
9984 for(int32_t j=0; j<2; j++)
6522 {
6523
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&tempitem.initiala[j],f,true))
6524 {
6525 return qe_invalid;
6526 }
6527 6656 }
6528
6529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
3328 if(s_version>4)
6530 {
6531
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version>5)
6532 {
6533
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.wpn,f,true))
6534 {
6535 return qe_invalid;
6536 }
6537
6538
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.wpn2,f,true))
6539 {
6540 return qe_invalid;
6541 }
6542
6543
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.wpn3,f,true))
6544 {
6545 return qe_invalid;
6546 }
6547
6548
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.wpn4,f,true))
6549 {
6550 return qe_invalid;
6551 }
6552
6553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
3328 if(s_version>=15)
6554 {
6555
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.wpn5,f,true))
6556 {
6557 return qe_invalid;
6558 }
6559
6560
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.wpn6,f,true))
6561 {
6562 return qe_invalid;
6563 }
6564
6565
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.wpn7,f,true))
6566 {
6567 return qe_invalid;
6568 }
6569
6570
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.wpn8,f,true))
6571 {
6572 return qe_invalid;
6573 }
6574
6575
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.wpn9,f,true))
6576 {
6577 return qe_invalid;
6578 }
6579
6580
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.wpn10,f,true))
6581 {
6582 return qe_invalid;
6583 }
6584 3328 }
6585
6586
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.pickup_hearts,f,true))
6587 {
6588 return qe_invalid;
6589 }
6590
6591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
3328 if(s_version<15)
6592 {
6593 if(!p_igetw(&dummy_word,f,true))
6594 {
6595 return qe_invalid;
6596 }
6597
6598 tempitem.misc1=dummy_word;
6599
6600 if(!p_igetw(&dummy_word,f,true))
6601 {
6602 return qe_invalid;
6603 }
6604
6605 tempitem.misc2=dummy_word;
6606 }
6607 else
6608 {
6609
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_igetl(&tempitem.misc1,f,true))
6610 {
6611 return qe_invalid;
6612 }
6613
6614
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_igetl(&tempitem.misc2,f,true))
6615 {
6616 return qe_invalid;
6617 }
6618
6619 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6620
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version<24)
6621 {
6622 if(tempitem.family==itype_shield)
6623 {
6624 tempitem.misc1|=shSCRIPT;
6625 }
6626 }
6627 }
6628
6629
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 512 times.
3328 if(s_version < 53)
6630 {
6631 byte tempbyte;
6632
1/2
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
2816 if(!p_getc(&tempbyte,f,true))
6633 {
6634 return qe_invalid;
6635 }
6636 2816 tempitem.cost_amount[0] = tempbyte;
6637 2816 }
6638 else
6639 {
6640
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 512 times.
1536 for(auto q = 0; q < 2; ++q)
6641 {
6642
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetw(&tempitem.cost_amount[q],f,true))
6643 {
6644 return qe_invalid;
6645 }
6646 1024 }
6647 }
6648 3328 }
6649 else
6650 {
6651 char tempchar;
6652
6653 if(!p_getc(&tempchar,f,true))
6654 {
6655 return qe_invalid;
6656 }
6657
6658 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6659 }
6660
6661 // June 2007: more misc. attributes
6662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
3328 if(s_version>=12)
6663 {
6664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
3328 if(s_version<15)
6665 {
6666 if(!p_igetw(&dummy_word,f,true))
6667 {
6668 return qe_invalid;
6669 }
6670
6671 tempitem.misc3=dummy_word;
6672
6673 if(!p_igetw(&dummy_word,f,true))
6674 {
6675 return qe_invalid;
6676 }
6677
6678 tempitem.misc4=dummy_word;
6679 }
6680 else
6681 {
6682
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_igetl(&tempitem.misc3,f,true))
6683 {
6684 return qe_invalid;
6685 }
6686
6687
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_igetl(&tempitem.misc4,f,true))
6688 {
6689 return qe_invalid;
6690 }
6691
6692
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_igetl(&tempitem.misc5,f,true))
6693 {
6694 return qe_invalid;
6695 }
6696
6697
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_igetl(&tempitem.misc6,f,true))
6698 {
6699 return qe_invalid;
6700 }
6701
6702
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_igetl(&tempitem.misc7,f,true))
6703 {
6704 return qe_invalid;
6705 }
6706
6707
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_igetl(&tempitem.misc8,f,true))
6708 {
6709 return qe_invalid;
6710 }
6711
6712
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_igetl(&tempitem.misc9,f,true))
6713 {
6714 return qe_invalid;
6715 }
6716
6717
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_igetl(&tempitem.misc10,f,true))
6718 {
6719 return qe_invalid;
6720 }
6721 }
6722
6723
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempitem.usesound,f,true))
6724 {
6725 return qe_invalid;
6726 }
6727
6728
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if(s_version >= 49)
6729 {
6730
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_getc(&tempitem.usesound2,f,true))
6731 {
6732 return qe_invalid;
6733 }
6734 512 }
6735 2816 else tempitem.usesound2 = 0;
6736
6737
3/4
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 512 times.
✓ Branch 2 taken 2816 times.
✗ Branch 3 not taken.
3328 if(s_version < 50 && tempitem.family == itype_mirror)
6738 {
6739 //Split continue/dmap warp effect/sfx, port for old
6740 tempitem.misc2 = tempitem.misc1;
6741 tempitem.usesound2 = tempitem.usesound;
6742 }
6743 3328 }
6744 3328 }
6745
6746
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 512 times.
3328 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6747 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6748
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_getc(&tempitem.useweapon,f,true))
6749 {
6750 return qe_invalid;
6751 }
6752
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_getc(&tempitem.usedefence,f,true))
6753 {
6754 return qe_invalid;
6755 }
6756
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.weaprange,f,true))
6757 {
6758 return qe_invalid;
6759 }
6760
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.weapduration,f,true))
6761 {
6762 return qe_invalid;
6763 }
6764
2/2
✓ Branch 0 taken 5120 times.
✓ Branch 1 taken 512 times.
5632 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6765 {
6766
1/2
✓ Branch 0 taken 5120 times.
✗ Branch 1 not taken.
5120 if(!p_igetl(&tempitem.weap_pattern[q],f,true))
6767 {
6768 return qe_invalid;
6769 }
6770 5120 }
6771 512 }
6772
6773
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 512 times.
3328 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6774 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6775
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.duplicates,f,true))
6776 {
6777 return qe_invalid;
6778 }
6779
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 512 times.
4608 for ( int32_t q = 0; q < INITIAL_D; q++ )
6780 {
6781
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(!p_igetl(&tempitem.weap_initiald[q],f,true))
6782 {
6783 return qe_invalid;
6784 }
6785 4096 }
6786
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 512 times.
1536 for ( int32_t q = 0; q < INITIAL_A; q++ )
6787 {
6788
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&tempitem.weap_initiala[q],f,true))
6789 {
6790 return qe_invalid;
6791 }
6792 1024 }
6793
6794
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_getc(&tempitem.drawlayer,f,true))
6795 {
6796 return qe_invalid;
6797 }
6798
6799
6800
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.hxofs,f,true))
6801 {
6802 return qe_invalid;
6803 }
6804
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.hyofs,f,true))
6805 {
6806 return qe_invalid;
6807 }
6808
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.hxsz,f,true))
6809 {
6810 return qe_invalid;
6811 }
6812
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.hysz,f,true))
6813 {
6814 return qe_invalid;
6815 }
6816
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.hzsz,f,true))
6817 {
6818 return qe_invalid;
6819 }
6820
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.xofs,f,true))
6821 {
6822 return qe_invalid;
6823 }
6824
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.yofs,f,true))
6825 {
6826 return qe_invalid;
6827 }
6828
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.weap_hxofs,f,true))
6829 {
6830 return qe_invalid;
6831 }
6832
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.weap_hyofs,f,true))
6833 {
6834 return qe_invalid;
6835 }
6836
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.weap_hxsz,f,true))
6837 {
6838 return qe_invalid;
6839 }
6840
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.weap_hysz,f,true))
6841 {
6842 return qe_invalid;
6843 }
6844
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.weap_hzsz,f,true))
6845 {
6846 return qe_invalid;
6847 }
6848
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.weap_xofs,f,true))
6849 {
6850 return qe_invalid;
6851 }
6852
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.weap_yofs,f,true))
6853 {
6854 return qe_invalid;
6855 }
6856
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetw(&tempitem.weaponscript,f,true))
6857 {
6858 return qe_invalid;
6859 }
6860
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.wpnsprite,f,true))
6861 {
6862 return qe_invalid;
6863 }
6864 512 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6865
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 512 times.
1536 for(auto q = 0; q < num_cost_tmr; ++q)
6866 {
6867
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&tempitem.magiccosttimer[q],f,true))
6868 {
6869 return qe_invalid;
6870 }
6871 1024 }
6872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 for(auto q = num_cost_tmr; q < 2; ++q)
6873 tempitem.magiccosttimer[q] = 0;
6874 512 }
6875
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 512 times.
3328 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6876 {
6877 //Item Size FLags, TileWidth, TileHeight
6878
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.overrideFLAGS,f,true))
6879 {
6880 return qe_invalid;
6881 }
6882
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.tilew,f,true))
6883 {
6884 return qe_invalid;
6885 }
6886
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.tileh,f,true))
6887 {
6888 return qe_invalid;
6889 }
6890 512 }
6891
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 512 times.
3328 if ( s_version >= 29 ) //! More new vars.
6892 {
6893 //Item Size FLags, TileWidth, TileHeight
6894
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.weapoverrideFLAGS,f,true))
6895 {
6896 return qe_invalid;
6897 }
6898
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.weap_tilew,f,true))
6899 {
6900 return qe_invalid;
6901 }
6902
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.weap_tileh,f,true))
6903 {
6904 return qe_invalid;
6905 }
6906 512 }
6907
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 512 times.
3328 if ( s_version >= 30 ) //! More new vars.
6908 {
6909 //Pickup Type
6910
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempitem.pickup,f,true))
6911 {
6912 return qe_invalid;
6913 }
6914 512 }
6915
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 512 times.
3328 if ( s_version >= 32 ) //! More new vars.
6916 {
6917 //Pickup Type
6918
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetw(&tempitem.pstring,f,true))
6919 {
6920 return qe_invalid;
6921 }
6922 512 }
6923
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 512 times.
3328 if ( s_version >= 33 ) //! More new vars.
6924 {
6925 //Pickup Type
6926
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetw(&tempitem.pickup_string_flags,f,true))
6927 {
6928 return qe_invalid;
6929 }
6930 512 }
6931
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 512 times.
3328 if ( s_version >= 34 ) //! cost counter
6932 {
6933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 if(s_version < 53)
6934 {
6935 if(!p_getc(&tempitem.cost_counter[0],f,true))
6936 {
6937 return qe_invalid;
6938 }
6939 }
6940 else
6941 {
6942
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 512 times.
1536 for(auto q = 0; q < 2; ++q)
6943 {
6944
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&tempitem.cost_counter[q],f,true))
6945 {
6946 return qe_invalid;
6947 }
6948 1024 }
6949 }
6950 512 }
6951
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 512 times.
3328 if ( s_version >= 44 ) //! sprite scripts
6952 {
6953
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 512 times.
4608 for ( int32_t q = 0; q < 8; q++ )
6954 {
6955
2/2
✓ Branch 0 taken 266240 times.
✓ Branch 1 taken 4096 times.
270336 for ( int32_t w = 0; w < 65; w++ )
6956 {
6957
1/2
✓ Branch 0 taken 266240 times.
✗ Branch 1 not taken.
266240 if(!p_getc(&(tempitem.initD_label[q][w]),f,keepdata))
6958 {
6959 return qe_invalid;
6960 }
6961 266240 }
6962
2/2
✓ Branch 0 taken 266240 times.
✓ Branch 1 taken 4096 times.
270336 for ( int32_t w = 0; w < 65; w++ )
6963 {
6964
1/2
✓ Branch 0 taken 266240 times.
✗ Branch 1 not taken.
266240 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f,keepdata))
6965 {
6966 return qe_invalid;
6967 }
6968 266240 }
6969
2/2
✓ Branch 0 taken 266240 times.
✓ Branch 1 taken 4096 times.
270336 for ( int32_t w = 0; w < 65; w++ )
6970 {
6971
1/2
✓ Branch 0 taken 266240 times.
✗ Branch 1 not taken.
266240 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f,keepdata))
6972 {
6973 return qe_invalid;
6974 }
6975 266240 }
6976
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(!p_igetl(&(tempitem.sprite_initiald[q]),f,keepdata))
6977 {
6978 return qe_invalid;
6979 }
6980
6981 4096 }
6982
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 512 times.
1536 for ( int32_t q = 0; q < 2; q++ )
6983 {
6984
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&(tempitem.sprite_initiala[q]),f,keepdata))
6985 {
6986 return qe_invalid;
6987 }
6988 1024 }
6989 //Pickup Type
6990
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetw(&tempitem.sprite_script,f,true))
6991 {
6992 return qe_invalid;
6993 }
6994 512 }
6995
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 512 times.
3328 if ( s_version >= 48 ) //! pickup flags
6996 {
6997
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_getc(&(tempitem.pickupflag),f,keepdata))
6998 {
6999 return qe_invalid;
7000 }
7001 512 }
7002 3328 }
7003 else
7004 {
7005 tempitem.count=-1;
7006 tempitem.family=itype_misc;
7007 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7008 tempitem.playsound=WAV_SCALE;
7009 reset_itembuf(&tempitem,i);
7010 }
7011
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if(s_version < 53)
7012 {
7013
4/4
✓ Branch 0 taken 2760 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 11 times.
2816 switch(tempitem.family)
7014 {
7015 case itype_arrow:
7016 33 tempitem.cost_counter[1] = crARROWS;
7017 33 tempitem.cost_amount[1] = 1;
7018 33 break;
7019 case itype_bomb:
7020 12 tempitem.cost_counter[1] = crBOMBS;
7021 12 tempitem.cost_amount[1] = 1;
7022 12 break;
7023 case itype_sbomb:
7024 11 tempitem.cost_counter[1] = crSBOMBS;
7025 11 tempitem.cost_amount[1] = 1;
7026 11 break;
7027 default:
7028 2760 tempitem.cost_counter[1] = crNONE;
7029 2760 tempitem.cost_amount[1] = 0;
7030 2760 }
7031 2816 tempitem.magiccosttimer[1] = 0;
7032 2816 }
7033
7034
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(keepdata==true)
7035 {
7036 3328 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7037 3328 }
7038 else if(zgpmode)
7039 {
7040 itemsbuf[i].tile=tempitem.tile;
7041 itemsbuf[i].misc_flags=tempitem.misc_flags;
7042 itemsbuf[i].csets=tempitem.csets;
7043 itemsbuf[i].frames=tempitem.frames;
7044 itemsbuf[i].speed=tempitem.speed;
7045 itemsbuf[i].delay=tempitem.delay;
7046 itemsbuf[i].ltm=tempitem.ltm;
7047 }
7048 3328 }
7049
7050 //////////////////////////////////////////////////////
7051 // Now do any updates because of new item additions
7052 // (These can't be done above because items_to_read
7053 // might be too low.)
7054 //////////////////////////////////////////////////////
7055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata==true)
7056 {
7057
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<MAXITEMS; i++)
7058 {
7059 3328 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7060
7061 //Account for older quests that didn't have an actual item for the used letter
7062
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3328 if(s_version < 2 && i==iLetterUsed)
7063 {
7064 reset_itembuf(&tempitem, iLetterUsed);
7065 strcpy(item_string[i],old_item_string[i]);
7066 tempitem.tile = itemsbuf[iLetter].tile;
7067 tempitem.csets = itemsbuf[iLetter].csets;
7068 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7069 tempitem.frames = itemsbuf[iLetter].frames;
7070 tempitem.speed = itemsbuf[iLetter].speed;
7071 tempitem.ltm = itemsbuf[iLetter].ltm;
7072 }
7073
7074
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 3)
7075 {
7076 switch(i)
7077 {
7078 case iRocsFeather:
7079 case iHoverBoots:
7080 case iSpinScroll:
7081 case iL2SpinScroll:
7082 case iCrossScroll:
7083 case iQuakeScroll:
7084 case iL2QuakeScroll:
7085 case iWhispRing:
7086 case iL2WhispRing:
7087 case iChargeRing:
7088 case iL2ChargeRing:
7089 case iPerilScroll:
7090 case iWalletL3:
7091 case iQuiverL4:
7092 case iBombBagL4:
7093 case iBracelet:
7094 case iL2Bracelet:
7095 case iOldGlove:
7096 case iL2Ladder:
7097 case iWealthMedal:
7098 case iL2WealthMedal:
7099 case iL3WealthMedal:
7100 reset_itembuf(&tempitem, i);
7101 strcpy(item_string[i],old_item_string[i]);
7102 break;
7103
7104 case iSShield:
7105 reset_itembuf(&tempitem, i);
7106 strcpy(item_string[i],old_item_string[i]);
7107 strcpy(item_string[iShield],old_item_string[iShield]);
7108 strcpy(item_string[iMShield],old_item_string[iMShield]);
7109 break;
7110 }
7111 }
7112
7113
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 5)
7114 {
7115 switch(i)
7116 {
7117 case iHeartRing:
7118 case iL2HeartRing:
7119 case iL3HeartRing:
7120 case iMagicRing:
7121 case iL2MagicRing:
7122 case iL3MagicRing:
7123 case iL4MagicRing:
7124 reset_itembuf(&tempitem, i);
7125 strcpy(item_string[i],old_item_string[i]);
7126 break;
7127 }
7128 }
7129
7130
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7131 {
7132 if(i!=iBPotion && i!=iRPotion)
7133 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7134
7135 switch(i)
7136 {
7137 case iTriforce:
7138 tempitem.fam_type=1;
7139 break;
7140
7141 case iBigTri:
7142 tempitem.fam_type=0;
7143 break;
7144
7145 case iBombs:
7146 tempitem.fam_type=i_bomb;
7147 tempitem.power=4;
7148 tempitem.wpn=wBOMB;
7149 tempitem.wpn2=wBOOM;
7150 tempitem.misc1 = 50;
7151
7152 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 200; //qr_SLOWBOMBFUSES
7153
7154 break;
7155
7156 case iSBomb:
7157 tempitem.fam_type=i_sbomb;
7158 tempitem.power=16;
7159 tempitem.wpn=wSBOMB;
7160 tempitem.wpn2=wSBOOM;
7161 tempitem.misc1 = 50;
7162
7163 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 400; //qr_SLOWBOMBFUSES
7164
7165 break;
7166
7167 case iBook:
7168 if(get_bit(deprecated_rules, 113))
7169 tempitem.wpn = wFIREMAGIC; //qr_FIREMAGICSPRITE
7170
7171 break;
7172
7173 case iSArrow:
7174 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7175 tempitem.power=4;
7176 tempitem.flags|=ITEM_GAMEDATA;
7177 tempitem.wpn=wSARROW;
7178 break;
7179
7180 case iGArrow:
7181 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7182 tempitem.power=8;
7183 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7184 tempitem.wpn=wGARROW;
7185 break;
7186
7187 case iBrang:
7188 tempitem.power=0;
7189 tempitem.wpn=wBRANG;
7190 tempitem.misc1=36;
7191 break;
7192
7193 case iMBrang:
7194 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7195 tempitem.power=0;
7196 tempitem.wpn=wMBRANG;
7197 break;
7198
7199 case iFBrang:
7200 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7201 tempitem.power=2;
7202 tempitem.wpn=wFBRANG;
7203 break;
7204
7205 case iBoots:
7206 tempitem.cost_amount[0] = get_bit(deprecated_rules,51) ? 1 : 0;
7207 tempitem.power=7;
7208 break;
7209
7210 case iWand:
7211 tempitem.cost_amount[0] = get_bit(deprecated_rules,49) ? 8 : 0;
7212 tempitem.power=2;
7213 tempitem.wpn=wWAND;
7214 tempitem.wpn3=wMAGIC;
7215 break;
7216
7217 case iBCandle:
7218 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7219 tempitem.power=1;
7220 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7221 tempitem.wpn3=wFIRE;
7222 break;
7223
7224 case iRCandle:
7225 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7226 tempitem.power=1;
7227 tempitem.wpn3=wFIRE;
7228 break;
7229
7230 case iSword:
7231 tempitem.power=1;
7232 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7233 tempitem.wpn=tempitem.wpn3=wSWORD;
7234 tempitem.wpn2=wSWORDSLASH;
7235 break;
7236
7237 case iWSword:
7238 tempitem.power=2;
7239 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7240 tempitem.wpn=tempitem.wpn3=wWSWORD;
7241 tempitem.wpn2=wWSWORDSLASH;
7242 break;
7243
7244 case iMSword:
7245 tempitem.power=4;
7246 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7247 tempitem.wpn=tempitem.wpn3=wMSWORD;
7248 tempitem.wpn2=wMSWORDSLASH;
7249 break;
7250
7251 case iXSword:
7252 tempitem.power=8;
7253 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7254 tempitem.wpn=tempitem.wpn3=wXSWORD;
7255 tempitem.wpn2=wXSWORDSLASH;
7256 break;
7257
7258 case iNayrusLove:
7259 tempitem.flags |= get_bit(deprecated_rules,76) ? ITEM_FLAG1 : 0;
7260 tempitem.flags |= get_bit(deprecated_rules,75) ? ITEM_FLAG2 : 0;
7261 tempitem.wpn=wNAYRUSLOVE1A;
7262 tempitem.wpn2=wNAYRUSLOVE1B;
7263 tempitem.wpn3=wNAYRUSLOVES1A;
7264 tempitem.wpn4=wNAYRUSLOVES1B;
7265 tempitem.wpn6=wNAYRUSLOVE2A;
7266 tempitem.wpn7=wNAYRUSLOVE2B;
7267 tempitem.wpn8=wNAYRUSLOVES2A;
7268 tempitem.wpn9=wNAYRUSLOVES2B;
7269 tempitem.wpn5 = iwNayrusLoveShieldFront;
7270 tempitem.wpn10 = iwNayrusLoveShieldBack;
7271 tempitem.misc1=512;
7272 tempitem.cost_amount[0]=64;
7273 break;
7274
7275 case iLens:
7276 tempitem.misc1=60;
7277 tempitem.flags |= get_bit(quest_rules,qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7278 tempitem.cost_amount[0] = get_bit(quest_rules,qr_ENABLEMAGIC) ? 2 : 1;
7279 break;
7280
7281 case iArrow:
7282 tempitem.power=2;
7283 tempitem.wpn=wARROW;
7284 break;
7285
7286 case iHoverBoots:
7287 tempitem.misc1=45;
7288 tempitem.wpn=iwHover;
7289 break;
7290
7291 case iDinsFire:
7292 tempitem.power=8;
7293 tempitem.wpn=wDINSFIRE1A;
7294 tempitem.wpn2=wDINSFIRE1B;
7295 tempitem.wpn3=wDINSFIRES1A;
7296 tempitem.wpn4=wDINSFIRES1B;
7297 tempitem.misc1 = 32;
7298 tempitem.misc2 = 200;
7299 tempitem.cost_amount[0]=32;
7300 break;
7301
7302 case iFaroresWind:
7303 tempitem.cost_amount[0]=32;
7304 break;
7305
7306 case iHookshot:
7307 tempitem.power=0;
7308 tempitem.flags&=~ITEM_FLAG1;
7309 tempitem.wpn=wHSHEAD;
7310 tempitem.wpn2=wHSCHAIN_H;
7311 tempitem.wpn4=wHSHANDLE;
7312 tempitem.wpn3=wHSCHAIN_V;
7313 tempitem.misc1=50;
7314 tempitem.misc2=100;
7315 break;
7316
7317 case iLongshot:
7318 tempitem.power=0;
7319 tempitem.flags&=~ITEM_FLAG1;
7320 tempitem.wpn=wLSHEAD;
7321 tempitem.wpn2=wLSCHAIN_H;
7322 tempitem.wpn4=wLSHANDLE;
7323 tempitem.wpn3=wLSCHAIN_V;
7324 tempitem.misc1=99;
7325 tempitem.misc2=100;
7326 break;
7327
7328 case iHammer:
7329 tempitem.power=4;
7330 tempitem.wpn=wHAMMER;
7331 tempitem.wpn2=iwHammerSmack;
7332 break;
7333
7334 case iCByrna:
7335 tempitem.power=1;
7336 tempitem.wpn=wCBYRNA;
7337 tempitem.wpn2=wCBYRNASLASH;
7338 tempitem.wpn3=wCBYRNAORB;
7339 tempitem.misc1=4;
7340 tempitem.misc2=16;
7341 tempitem.misc3=1;
7342 tempitem.cost_amount[0]=1;
7343 break;
7344
7345 case iWhistle:
7346 tempitem.wpn=wWIND;
7347 tempitem.misc1=3;
7348 tempitem.flags|=ITEM_FLAG1;
7349 break;
7350
7351 case iBRing:
7352 tempitem.power=2;
7353 tempitem.misc1=spBLUE;
7354 break;
7355
7356 case iRRing:
7357 tempitem.power=4;
7358 tempitem.misc1=spRED;
7359 break;
7360
7361 case iGRing:
7362 tempitem.power=8;
7363 tempitem.misc1=spGOLD;
7364 break;
7365
7366 case iSpinScroll:
7367 tempitem.power = 2;
7368 tempitem.misc1 = 1;
7369 break;
7370
7371 case iL2SpinScroll:
7372 tempitem.family=itype_spinscroll2;
7373 tempitem.fam_type=1;
7374 tempitem.cost_amount[0]=8;
7375 tempitem.power=2;
7376 tempitem.misc1 = 20;
7377 break;
7378
7379 case iQuakeScroll:
7380 tempitem.misc1=0x10;
7381 tempitem.misc2=64;
7382 break;
7383
7384 case iL2QuakeScroll:
7385 tempitem.family=itype_quakescroll2;
7386 tempitem.fam_type=1;
7387 tempitem.power = 2;
7388 tempitem.misc1=0x20;
7389 tempitem.misc2=192;
7390 tempitem.cost_amount[0]=8;
7391 break;
7392
7393 case iChargeRing:
7394 tempitem.misc1=64;
7395 tempitem.misc2=128;
7396 break;
7397
7398 case iL2ChargeRing:
7399 tempitem.misc1=32;
7400 tempitem.misc2=64;
7401 break;
7402
7403 case iOldGlove:
7404 tempitem.flags |= ITEM_FLAG1;
7405
7406 //fallthrough
7407 case iBombBagL4:
7408 case iWalletL3:
7409 case iQuiverL4:
7410 case iBracelet:
7411 tempitem.power = 1;
7412 break;
7413
7414 case iL2Bracelet:
7415 tempitem.power = 2;
7416 break;
7417
7418 case iMKey:
7419 tempitem.power=0xFF;
7420 tempitem.flags |= ITEM_FLAG1;
7421 break;
7422 }
7423 }
7424
7425
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 7)
7426 {
7427 switch(i)
7428 {
7429 case iStoneAgony:
7430 case iStompBoots:
7431 case iPerilRing:
7432 case iWhimsicalRing:
7433 {
7434 reset_itembuf(&tempitem, i);
7435 strcpy(item_string[i],old_item_string[i]);
7436 break;
7437 }
7438 }
7439 }
7440
7441
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 8) // May 2007: Some corrections.
7442 {
7443 switch(i)
7444 {
7445 case iMShield:
7446 tempitem.misc1|=shFLAME;
7447 tempitem.misc2|=shFIREBALL|shMAGIC;
7448
7449 if(get_bit(quest_rules, qr_SWORDMIRROR))
7450 {
7451 tempitem.misc2 |= shSWORD;
7452 }
7453
7454 // fallthrough
7455 case iShield:
7456 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7457
7458 // fallthrough
7459 case iSShield:
7460 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7461
7462 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7463 {
7464 tempitem.misc2 |= shROCK;
7465 }
7466
7467 break;
7468
7469 case iWhispRing:
7470 tempitem.power=1;
7471 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7472 tempitem.misc1 = 3;
7473 break;
7474
7475 case iL2WhispRing:
7476 tempitem.power=0;
7477 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7478 tempitem.misc1 = 3;
7479 break;
7480
7481 case iL2Ladder:
7482 case iBow:
7483 case iCByrna:
7484 tempitem.power = 1;
7485 break;
7486 }
7487 }
7488
7489
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3328 if(s_version < 9 && i==iClock)
7490 {
7491 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7492 }
7493
7494 //add the misc flag for bomb
7495
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3328 if(s_version < 10 && tempitem.family == itype_bomb)
7496 {
7497 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_bit(quest_rules, qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7498 }
7499
7500
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3328 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7501 {
7502 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7503 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7504 }
7505
7506
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 12) // June 2007: More Misc. attributes.
7507 {
7508 switch(i)
7509 {
7510 case iFBrang:
7511 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7512
7513 //fallthrough
7514 case iMBrang:
7515 tempitem.misc3 |= shSWORD|shMAGIC;
7516
7517 //fallthrough
7518 case iHookshot:
7519 case iLongshot:
7520 //fallthrough
7521 tempitem.misc3 |= shFIREBALL;
7522
7523 case iBrang:
7524 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7525 break;
7526 }
7527
7528 switch(tempitem.family)
7529 {
7530 case itype_hoverboots:
7531 tempitem.usesound = WAV_ZN1HOVER;
7532 break;
7533
7534 case itype_wand:
7535 case itype_book:
7536 tempitem.usesound = WAV_WAND;
7537 break;
7538
7539 case itype_arrow:
7540 tempitem.usesound = WAV_ARROW;
7541 break;
7542
7543 case itype_hookshot:
7544 tempitem.usesound = WAV_HOOKSHOT;
7545 break;
7546
7547 case itype_brang:
7548 tempitem.usesound = WAV_BRANG;
7549 break;
7550
7551 case itype_shield:
7552 tempitem.usesound = WAV_CHINK;
7553 break;
7554
7555 case itype_sword:
7556 tempitem.usesound = WAV_SWORD;
7557 break;
7558
7559 case itype_whistle:
7560 tempitem.usesound = WAV_WHISTLE;
7561 break;
7562
7563 case itype_hammer:
7564 tempitem.usesound = WAV_HAMMER;
7565 break;
7566
7567 case itype_dinsfire:
7568 tempitem.usesound = WAV_ZN1DINSFIRE;
7569 break;
7570
7571 case itype_faroreswind:
7572 tempitem.usesound = WAV_ZN1FARORESWIND;
7573 break;
7574
7575 case itype_nayruslove:
7576 tempitem.usesound = WAV_ZN1NAYRUSLOVE1;
7577 break;
7578
7579 case itype_bomb:
7580 case itype_sbomb:
7581 case itype_quakescroll:
7582 case itype_quakescroll2:
7583 tempitem.usesound = WAV_BOMB;
7584 break;
7585
7586 case itype_spinscroll:
7587 case itype_spinscroll2:
7588 tempitem.usesound = WAV_ZN1SPINATTACK;
7589 break;
7590 }
7591 }
7592
7593
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 13) // July 2007
7594 {
7595 if(tempitem.family == itype_whistle)
7596 {
7597 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7598 tempitem.power = 1;
7599 tempitem.flags|=ITEM_FLAG1;
7600 }
7601 else if(tempitem.family == itype_wand)
7602 tempitem.flags|=ITEM_FLAG1;
7603 else if(tempitem.family == itype_book)
7604 {
7605 tempitem.flags|=ITEM_FLAG1;
7606 tempitem.power = 2;
7607 }
7608 }
7609
7610
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 14) // August 2007
7611 {
7612 if(tempitem.family == itype_fairy)
7613 {
7614 tempitem.usesound = WAV_SCALE;
7615
7616 if(tempitem.fam_type)
7617 tempitem.misc3=50;
7618 }
7619 else if(tempitem.family == itype_potion)
7620 {
7621 tempitem.flags |= ITEM_GAINOLD;
7622 }
7623 }
7624
7625
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 17) // November 2007
7626 {
7627 if(tempitem.family == itype_candle && !tempitem.wpn3)
7628 {
7629 tempitem.wpn3 = wFIRE;
7630 }
7631 else if(tempitem.family == itype_arrow && tempitem.power>4)
7632 {
7633 tempitem.flags|=ITEM_FLAG1;
7634 }
7635 }
7636
7637
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 18) // New Year's Eve 2007
7638 {
7639 if(tempitem.family == itype_whistle)
7640 tempitem.misc2 = 8; // Use the Whistle warp ring
7641 else if(tempitem.family == itype_bait)
7642 tempitem.misc1 = 768; // Frames until it goes
7643 else if(tempitem.family == itype_triforcepiece)
7644 {
7645 if(tempitem.flags & ITEM_GAMEDATA)
7646 {
7647 tempitem.misc2 = 1; // Cutscene 1
7648 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7649 }
7650 }
7651 }
7652
7653
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 19) // January 2008
7654 {
7655 if(tempitem.family == itype_nayruslove)
7656 {
7657 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7658 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7659 }
7660 }
7661
7662
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 20) // October 2008
7663 {
7664 if(tempitem.family == itype_nayruslove)
7665 {
7666 tempitem.wpn6=wNAYRUSLOVE2A;
7667 tempitem.wpn7=wNAYRUSLOVE2B;
7668 tempitem.wpn8=wNAYRUSLOVES2A;
7669 tempitem.wpn9=wNAYRUSLOVES2B;
7670 tempitem.wpn5 = iwNayrusLoveShieldFront;
7671 tempitem.wpn10 = iwNayrusLoveShieldBack;
7672 }
7673 }
7674
7675
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 21) // November 2008
7676 {
7677 if(tempitem.flags & 0x0100) // ITEM_SLASH
7678 {
7679 tempitem.flags &= ~0x0100;
7680
7681 if(tempitem.family == itype_sword ||
7682 tempitem.family == itype_wand ||
7683 tempitem.family == itype_candle ||
7684 tempitem.family == itype_cbyrna)
7685 {
7686 tempitem.flags |= ITEM_FLAG4;
7687 }
7688 }
7689 }
7690
7691
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 22) // September 2009
7692 {
7693 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7694 {
7695 tempitem.misc3 = tempitem.power/2;
7696 }
7697 }
7698
7699
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 23) // March 2011
7700 {
7701 if(tempitem.family == itype_dinsfire)
7702 tempitem.wpn5 = wFIRE;
7703 else if(tempitem.family == itype_book)
7704 tempitem.wpn2 = wFIRE;
7705 }
7706
7707 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7708 // whether it was or not, and a lot of existing quests depended on the
7709 // incorrect behavior.
7710
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 25) // January 2012
7711 {
7712 if(tempitem.family == itype_bombbag)
7713 tempitem.flags |= 16;
7714
7715 if(tempitem.family == itype_dinsfire)
7716 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7717 }
7718
7719
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7720 {
7721
60/60
✓ Branch 0 taken 986 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 127 times.
✓ Branch 4 taken 219 times.
✓ Branch 5 taken 342 times.
✓ Branch 6 taken 33 times.
✓ Branch 7 taken 33 times.
✓ Branch 8 taken 24 times.
✓ Branch 9 taken 13 times.
✓ Branch 10 taken 11 times.
✓ Branch 11 taken 22 times.
✓ Branch 12 taken 22 times.
✓ Branch 13 taken 12 times.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 33 times.
✓ Branch 16 taken 22 times.
✓ Branch 17 taken 33 times.
✓ Branch 18 taken 22 times.
✓ Branch 19 taken 11 times.
✓ Branch 20 taken 22 times.
✓ Branch 21 taken 12 times.
✓ Branch 22 taken 11 times.
✓ Branch 23 taken 33 times.
✓ Branch 24 taken 11 times.
✓ Branch 25 taken 11 times.
✓ Branch 26 taken 22 times.
✓ Branch 27 taken 11 times.
✓ Branch 28 taken 11 times.
✓ Branch 29 taken 11 times.
✓ Branch 30 taken 11 times.
✓ Branch 31 taken 11 times.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 11 times.
✓ Branch 34 taken 11 times.
✓ Branch 35 taken 11 times.
✓ Branch 36 taken 11 times.
✓ Branch 37 taken 22 times.
✓ Branch 38 taken 44 times.
✓ Branch 39 taken 11 times.
✓ Branch 40 taken 11 times.
✓ Branch 41 taken 21 times.
✓ Branch 42 taken 44 times.
✓ Branch 43 taken 11 times.
✓ Branch 44 taken 11 times.
✓ Branch 45 taken 11 times.
✓ Branch 46 taken 11 times.
✓ Branch 47 taken 11 times.
✓ Branch 48 taken 22 times.
✓ Branch 49 taken 22 times.
✓ Branch 50 taken 11 times.
✓ Branch 51 taken 33 times.
✓ Branch 52 taken 33 times.
✓ Branch 53 taken 44 times.
✓ Branch 54 taken 11 times.
✓ Branch 55 taken 11 times.
✓ Branch 56 taken 11 times.
✓ Branch 57 taken 11 times.
✓ Branch 58 taken 11 times.
✓ Branch 59 taken 11 times.
2816 switch(tempitem.family)
7722 {
7723 case itype_sword:
7724 {
7725 342 tempitem.flags &= ~(ITEM_FLAG5);
7726 342 tempitem.misc3 = 0;
7727 342 tempitem.misc4 = 0;
7728 342 tempitem.misc5 = 0;
7729 342 tempitem.misc6 = 0;
7730 342 tempitem.misc7 = 0;
7731 342 tempitem.misc8 = 0;
7732 342 tempitem.misc9 = 0;
7733 342 tempitem.misc10 = 0;
7734 342 tempitem.wpn4 = 0;
7735 342 tempitem.wpn5 = 0;
7736 342 tempitem.wpn6 = 0;
7737 342 tempitem.wpn7 = 0;
7738 342 tempitem.wpn8 = 0;
7739 342 tempitem.wpn9 = 0;
7740 342 tempitem.wpn10 = 0;
7741 342 break;
7742 }
7743 case itype_brang:
7744 {
7745 33 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7746 33 tempitem.misc2 = 0;
7747 33 tempitem.misc5 = 0;
7748 33 tempitem.misc6 = 0;
7749 33 tempitem.misc7 = 0;
7750 33 tempitem.misc8 = 0;
7751 33 tempitem.misc9 = 0;
7752 33 tempitem.misc10 = 0;
7753 33 tempitem.wpn4 = 0;
7754 33 tempitem.wpn5 = 0;
7755 33 tempitem.wpn6 = 0;
7756 33 tempitem.wpn7 = 0;
7757 33 tempitem.wpn8 = 0;
7758 33 tempitem.wpn9 = 0;
7759 33 tempitem.wpn10 = 0;
7760 33 break;
7761 }
7762 case itype_arrow:
7763 {
7764 33 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7765 33 tempitem.misc2 = 0;
7766 33 tempitem.misc3 = 0;
7767 33 tempitem.misc4 = 0;
7768 33 tempitem.misc5 = 0;
7769 33 tempitem.misc6 = 0;
7770 33 tempitem.misc7 = 0;
7771 33 tempitem.misc8 = 0;
7772 33 tempitem.misc9 = 0;
7773 33 tempitem.misc10 = 0;
7774 33 tempitem.wpn4 = 0;
7775 33 tempitem.wpn5 = 0;
7776 33 tempitem.wpn6 = 0;
7777 33 tempitem.wpn7 = 0;
7778 33 tempitem.wpn8 = 0;
7779 33 tempitem.wpn9 = 0;
7780 33 tempitem.wpn10 = 0;
7781 33 break;
7782 }
7783 case itype_candle:
7784 {
7785 24 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7786 24 tempitem.misc1 = 0;
7787 24 tempitem.misc2 = 0;
7788 24 tempitem.misc3 = 0;
7789 24 tempitem.misc4 = 0;
7790 24 tempitem.misc5 = 0;
7791 24 tempitem.misc6 = 0;
7792 24 tempitem.misc7 = 0;
7793 24 tempitem.misc8 = 0;
7794 24 tempitem.misc9 = 0;
7795 24 tempitem.misc10 = 0;
7796 24 tempitem.wpn4 = 0;
7797 24 tempitem.wpn5 = 0;
7798 24 tempitem.wpn6 = 0;
7799 24 tempitem.wpn7 = 0;
7800 24 tempitem.wpn8 = 0;
7801 24 tempitem.wpn9 = 0;
7802 24 tempitem.wpn10 = 0;
7803 24 break;
7804 }
7805 case itype_whistle:
7806 {
7807 13 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7808 13 tempitem.misc3 = 0;
7809 13 tempitem.misc4 = 0;
7810 13 tempitem.misc5 = 0;
7811 13 tempitem.misc6 = 0;
7812 13 tempitem.misc7 = 0;
7813 13 tempitem.misc8 = 0;
7814 13 tempitem.misc9 = 0;
7815 13 tempitem.misc10 = 0;
7816 13 tempitem.wpn2 = 0;
7817 13 tempitem.wpn3 = 0;
7818 13 tempitem.wpn4 = 0;
7819 13 tempitem.wpn5 = 0;
7820 13 tempitem.wpn6 = 0;
7821 13 tempitem.wpn7 = 0;
7822 13 tempitem.wpn8 = 0;
7823 13 tempitem.wpn9 = 0;
7824 13 tempitem.wpn10 = 0;
7825 13 break;
7826 }
7827 case itype_bait:
7828 {
7829 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7830 11 tempitem.misc2 = 0;
7831 11 tempitem.misc3 = 0;
7832 11 tempitem.misc4 = 0;
7833 11 tempitem.misc5 = 0;
7834 11 tempitem.misc6 = 0;
7835 11 tempitem.misc7 = 0;
7836 11 tempitem.misc8 = 0;
7837 11 tempitem.misc9 = 0;
7838 11 tempitem.misc10 = 0;
7839 11 tempitem.wpn2 = 0;
7840 11 tempitem.wpn3 = 0;
7841 11 tempitem.wpn4 = 0;
7842 11 tempitem.wpn5 = 0;
7843 11 tempitem.wpn6 = 0;
7844 11 tempitem.wpn7 = 0;
7845 11 tempitem.wpn8 = 0;
7846 11 tempitem.wpn9 = 0;
7847 11 tempitem.wpn10 = 0;
7848 11 break;
7849 }
7850 case itype_letter:
7851 {
7852 22 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7853 22 tempitem.misc1 = 0;
7854 22 tempitem.misc2 = 0;
7855 22 tempitem.misc3 = 0;
7856 22 tempitem.misc4 = 0;
7857 22 tempitem.misc5 = 0;
7858 22 tempitem.misc6 = 0;
7859 22 tempitem.misc7 = 0;
7860 22 tempitem.misc8 = 0;
7861 22 tempitem.misc9 = 0;
7862 22 tempitem.misc10 = 0;
7863 22 tempitem.wpn = 0;
7864 22 tempitem.wpn2 = 0;
7865 22 tempitem.wpn3 = 0;
7866 22 tempitem.wpn4 = 0;
7867 22 tempitem.wpn5 = 0;
7868 22 tempitem.wpn6 = 0;
7869 22 tempitem.wpn7 = 0;
7870 22 tempitem.wpn8 = 0;
7871 22 tempitem.wpn9 = 0;
7872 22 tempitem.wpn10 = 0;
7873 22 break;
7874 }
7875 case itype_potion:
7876 {
7877 22 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7878 22 tempitem.misc3 = 0;
7879 22 tempitem.misc4 = 0;
7880 22 tempitem.misc5 = 0;
7881 22 tempitem.misc6 = 0;
7882 22 tempitem.misc7 = 0;
7883 22 tempitem.misc8 = 0;
7884 22 tempitem.misc9 = 0;
7885 22 tempitem.misc10 = 0;
7886 22 tempitem.wpn = 0;
7887 22 tempitem.wpn2 = 0;
7888 22 tempitem.wpn3 = 0;
7889 22 tempitem.wpn4 = 0;
7890 22 tempitem.wpn5 = 0;
7891 22 tempitem.wpn6 = 0;
7892 22 tempitem.wpn7 = 0;
7893 22 tempitem.wpn8 = 0;
7894 22 tempitem.wpn9 = 0;
7895 22 tempitem.wpn10 = 0;
7896 22 break;
7897 }
7898 case itype_wand:
7899 {
7900 12 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7901 12 tempitem.misc1 = 0;
7902 12 tempitem.misc2 = 0;
7903 12 tempitem.misc3 = 0;
7904 12 tempitem.misc4 = 0;
7905 12 tempitem.misc5 = 0;
7906 12 tempitem.misc6 = 0;
7907 12 tempitem.misc7 = 0;
7908 12 tempitem.misc8 = 0;
7909 12 tempitem.misc9 = 0;
7910 12 tempitem.misc10 = 0;
7911 12 tempitem.wpn4 = 0;
7912 12 tempitem.wpn5 = 0;
7913 12 tempitem.wpn6 = 0;
7914 12 tempitem.wpn7 = 0;
7915 12 tempitem.wpn8 = 0;
7916 12 tempitem.wpn9 = 0;
7917 12 tempitem.wpn10 = 0;
7918 12 break;
7919 }
7920 case itype_ring:
7921 {
7922 33 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7923 33 tempitem.misc2 = 0;
7924 33 tempitem.misc3 = 0;
7925 33 tempitem.misc4 = 0;
7926 33 tempitem.misc5 = 0;
7927 33 tempitem.misc6 = 0;
7928 33 tempitem.misc7 = 0;
7929 33 tempitem.misc8 = 0;
7930 33 tempitem.misc9 = 0;
7931 33 tempitem.misc10 = 0;
7932 33 tempitem.wpn = 0;
7933 33 tempitem.wpn2 = 0;
7934 33 tempitem.wpn3 = 0;
7935 33 tempitem.wpn4 = 0;
7936 33 tempitem.wpn5 = 0;
7937 33 tempitem.wpn6 = 0;
7938 33 tempitem.wpn7 = 0;
7939 33 tempitem.wpn8 = 0;
7940 33 tempitem.wpn9 = 0;
7941 33 tempitem.wpn10 = 0;
7942 33 break;
7943 }
7944 case itype_wallet:
7945 {
7946 33 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7947 33 tempitem.misc3 = 0;
7948 33 tempitem.misc4 = 0;
7949 33 tempitem.misc5 = 0;
7950 33 tempitem.misc6 = 0;
7951 33 tempitem.misc7 = 0;
7952 33 tempitem.misc8 = 0;
7953 33 tempitem.misc9 = 0;
7954 33 tempitem.misc10 = 0;
7955 33 tempitem.wpn = 0;
7956 33 tempitem.wpn2 = 0;
7957 33 tempitem.wpn3 = 0;
7958 33 tempitem.wpn4 = 0;
7959 33 tempitem.wpn5 = 0;
7960 33 tempitem.wpn6 = 0;
7961 33 tempitem.wpn7 = 0;
7962 33 tempitem.wpn8 = 0;
7963 33 tempitem.wpn9 = 0;
7964 33 tempitem.wpn10 = 0;
7965 33 break;
7966 }
7967 case itype_amulet:
7968 {
7969 22 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7970 22 tempitem.misc1 = 0;
7971 22 tempitem.misc2 = 0;
7972 22 tempitem.misc3 = 0;
7973 22 tempitem.misc4 = 0;
7974 22 tempitem.misc5 = 0;
7975 22 tempitem.misc6 = 0;
7976 22 tempitem.misc7 = 0;
7977 22 tempitem.misc8 = 0;
7978 22 tempitem.misc9 = 0;
7979 22 tempitem.misc10 = 0;
7980 22 tempitem.wpn = 0;
7981 22 tempitem.wpn2 = 0;
7982 22 tempitem.wpn3 = 0;
7983 22 tempitem.wpn4 = 0;
7984 22 tempitem.wpn5 = 0;
7985 22 tempitem.wpn6 = 0;
7986 22 tempitem.wpn7 = 0;
7987 22 tempitem.wpn8 = 0;
7988 22 tempitem.wpn9 = 0;
7989 22 tempitem.wpn10 = 0;
7990 22 break;
7991 }
7992 case itype_shield:
7993 {
7994 33 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7995 33 tempitem.misc3 = 0;
7996 33 tempitem.misc4 = 0;
7997 33 tempitem.misc5 = 0;
7998 33 tempitem.misc6 = 0;
7999 33 tempitem.misc7 = 0;
8000 33 tempitem.misc8 = 0;
8001 33 tempitem.misc9 = 0;
8002 33 tempitem.misc10 = 0;
8003 33 tempitem.wpn = 0;
8004 33 tempitem.wpn2 = 0;
8005 33 tempitem.wpn3 = 0;
8006 33 tempitem.wpn4 = 0;
8007 33 tempitem.wpn5 = 0;
8008 33 tempitem.wpn6 = 0;
8009 33 tempitem.wpn7 = 0;
8010 33 tempitem.wpn8 = 0;
8011 33 tempitem.wpn9 = 0;
8012 33 tempitem.wpn10 = 0;
8013 33 break;
8014 }
8015 case itype_bow:
8016 {
8017 22 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8018 22 tempitem.misc1 = 0;
8019 22 tempitem.misc2 = 0;
8020 22 tempitem.misc3 = 0;
8021 22 tempitem.misc4 = 0;
8022 22 tempitem.misc5 = 0;
8023 22 tempitem.misc6 = 0;
8024 22 tempitem.misc7 = 0;
8025 22 tempitem.misc8 = 0;
8026 22 tempitem.misc9 = 0;
8027 22 tempitem.misc10 = 0;
8028 22 tempitem.wpn = 0;
8029 22 tempitem.wpn2 = 0;
8030 22 tempitem.wpn3 = 0;
8031 22 tempitem.wpn4 = 0;
8032 22 tempitem.wpn5 = 0;
8033 22 tempitem.wpn6 = 0;
8034 22 tempitem.wpn7 = 0;
8035 22 tempitem.wpn8 = 0;
8036 22 tempitem.wpn9 = 0;
8037 22 tempitem.wpn10 = 0;
8038 22 break;
8039 }
8040 case itype_raft:
8041 {
8042 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8043 11 tempitem.misc1 = 0;
8044 11 tempitem.misc2 = 0;
8045 11 tempitem.misc3 = 0;
8046 11 tempitem.misc4 = 0;
8047 11 tempitem.misc5 = 0;
8048 11 tempitem.misc6 = 0;
8049 11 tempitem.misc7 = 0;
8050 11 tempitem.misc8 = 0;
8051 11 tempitem.misc9 = 0;
8052 11 tempitem.misc10 = 0;
8053 11 tempitem.wpn = 0;
8054 11 tempitem.wpn2 = 0;
8055 11 tempitem.wpn3 = 0;
8056 11 tempitem.wpn4 = 0;
8057 11 tempitem.wpn5 = 0;
8058 11 tempitem.wpn6 = 0;
8059 11 tempitem.wpn7 = 0;
8060 11 tempitem.wpn8 = 0;
8061 11 tempitem.wpn9 = 0;
8062 11 tempitem.wpn10 = 0;
8063 11 break;
8064 }
8065 case itype_ladder:
8066 {
8067 22 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8068 22 tempitem.misc1 = 0;
8069 22 tempitem.misc2 = 0;
8070 22 tempitem.misc3 = 0;
8071 22 tempitem.misc4 = 0;
8072 22 tempitem.misc5 = 0;
8073 22 tempitem.misc6 = 0;
8074 22 tempitem.misc7 = 0;
8075 22 tempitem.misc8 = 0;
8076 22 tempitem.misc9 = 0;
8077 22 tempitem.misc10 = 0;
8078 22 tempitem.wpn = 0;
8079 22 tempitem.wpn2 = 0;
8080 22 tempitem.wpn3 = 0;
8081 22 tempitem.wpn4 = 0;
8082 22 tempitem.wpn5 = 0;
8083 22 tempitem.wpn6 = 0;
8084 22 tempitem.wpn7 = 0;
8085 22 tempitem.wpn8 = 0;
8086 22 tempitem.wpn9 = 0;
8087 22 tempitem.wpn10 = 0;
8088 22 break;
8089 }
8090 case itype_book:
8091 {
8092 12 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8093 12 tempitem.misc1 = 0;
8094 12 tempitem.misc2 = 0;
8095 12 tempitem.misc3 = 0;
8096 12 tempitem.misc4 = 0;
8097 12 tempitem.misc5 = 0;
8098 12 tempitem.misc6 = 0;
8099 12 tempitem.misc7 = 0;
8100 12 tempitem.misc8 = 0;
8101 12 tempitem.misc9 = 0;
8102 12 tempitem.misc10 = 0;
8103 12 tempitem.wpn3 = 0;
8104 12 tempitem.wpn4 = 0;
8105 12 tempitem.wpn5 = 0;
8106 12 tempitem.wpn6 = 0;
8107 12 tempitem.wpn7 = 0;
8108 12 tempitem.wpn8 = 0;
8109 12 tempitem.wpn9 = 0;
8110 12 tempitem.wpn10 = 0;
8111 12 break;
8112 }
8113 case itype_magickey:
8114 {
8115 11 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8116 11 tempitem.misc1 = 0;
8117 11 tempitem.misc2 = 0;
8118 11 tempitem.misc3 = 0;
8119 11 tempitem.misc4 = 0;
8120 11 tempitem.misc5 = 0;
8121 11 tempitem.misc6 = 0;
8122 11 tempitem.misc7 = 0;
8123 11 tempitem.misc8 = 0;
8124 11 tempitem.misc9 = 0;
8125 11 tempitem.misc10 = 0;
8126 11 tempitem.wpn = 0;
8127 11 tempitem.wpn2 = 0;
8128 11 tempitem.wpn3 = 0;
8129 11 tempitem.wpn4 = 0;
8130 11 tempitem.wpn5 = 0;
8131 11 tempitem.wpn6 = 0;
8132 11 tempitem.wpn7 = 0;
8133 11 tempitem.wpn8 = 0;
8134 11 tempitem.wpn9 = 0;
8135 11 tempitem.wpn10 = 0;
8136 11 break;
8137 }
8138 case itype_bracelet:
8139 {
8140 33 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8141 33 tempitem.misc1 = 0;
8142 33 tempitem.misc2 = 0;
8143 33 tempitem.misc3 = 0;
8144 33 tempitem.misc4 = 0;
8145 33 tempitem.misc5 = 0;
8146 33 tempitem.misc6 = 0;
8147 33 tempitem.misc7 = 0;
8148 33 tempitem.misc8 = 0;
8149 33 tempitem.misc9 = 0;
8150 33 tempitem.misc10 = 0;
8151 33 tempitem.wpn = 0;
8152 33 tempitem.wpn2 = 0;
8153 33 tempitem.wpn3 = 0;
8154 33 tempitem.wpn4 = 0;
8155 33 tempitem.wpn5 = 0;
8156 33 tempitem.wpn6 = 0;
8157 33 tempitem.wpn7 = 0;
8158 33 tempitem.wpn8 = 0;
8159 33 tempitem.wpn9 = 0;
8160 33 tempitem.wpn10 = 0;
8161 33 break;
8162 }
8163 case itype_flippers:
8164 {
8165 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8166 11 tempitem.misc1 = 0;
8167 11 tempitem.misc2 = 0;
8168 11 tempitem.misc3 = 0;
8169 11 tempitem.misc4 = 0;
8170 11 tempitem.misc5 = 0;
8171 11 tempitem.misc6 = 0;
8172 11 tempitem.misc7 = 0;
8173 11 tempitem.misc8 = 0;
8174 11 tempitem.misc9 = 0;
8175 11 tempitem.misc10 = 0;
8176 11 tempitem.wpn = 0;
8177 11 tempitem.wpn2 = 0;
8178 11 tempitem.wpn3 = 0;
8179 11 tempitem.wpn4 = 0;
8180 11 tempitem.wpn5 = 0;
8181 11 tempitem.wpn6 = 0;
8182 11 tempitem.wpn7 = 0;
8183 11 tempitem.wpn8 = 0;
8184 11 tempitem.wpn9 = 0;
8185 11 tempitem.wpn10 = 0;
8186 11 break;
8187 }
8188 case itype_boots:
8189 {
8190 11 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8191 11 tempitem.misc1 = 0;
8192 11 tempitem.misc2 = 0;
8193 11 tempitem.misc3 = 0;
8194 11 tempitem.misc4 = 0;
8195 11 tempitem.misc5 = 0;
8196 11 tempitem.misc6 = 0;
8197 11 tempitem.misc7 = 0;
8198 11 tempitem.misc8 = 0;
8199 11 tempitem.misc9 = 0;
8200 11 tempitem.misc10 = 0;
8201 11 tempitem.wpn = 0;
8202 11 tempitem.wpn2 = 0;
8203 11 tempitem.wpn3 = 0;
8204 11 tempitem.wpn4 = 0;
8205 11 tempitem.wpn5 = 0;
8206 11 tempitem.wpn6 = 0;
8207 11 tempitem.wpn7 = 0;
8208 11 tempitem.wpn8 = 0;
8209 11 tempitem.wpn9 = 0;
8210 11 tempitem.wpn10 = 0;
8211 11 break;
8212 }
8213 case itype_hookshot:
8214 {
8215 22 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8216 22 tempitem.misc5 = 0;
8217 22 tempitem.misc6 = 0;
8218 22 tempitem.misc7 = 0;
8219 22 tempitem.misc8 = 0;
8220 22 tempitem.misc9 = 0;
8221 22 tempitem.misc10 = 0;
8222 22 tempitem.wpn5 = 0;
8223 22 tempitem.wpn6 = 0;
8224 22 tempitem.wpn7 = 0;
8225 22 tempitem.wpn8 = 0;
8226 22 tempitem.wpn9 = 0;
8227 22 tempitem.wpn10 = 0;
8228 22 break;
8229 }
8230 case itype_lens:
8231 {
8232 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8233 11 tempitem.misc2 = 0;
8234 11 tempitem.misc3 = 0;
8235 11 tempitem.misc4 = 0;
8236 11 tempitem.misc5 = 0;
8237 11 tempitem.misc6 = 0;
8238 11 tempitem.misc7 = 0;
8239 11 tempitem.misc8 = 0;
8240 11 tempitem.misc9 = 0;
8241 11 tempitem.misc10 = 0;
8242 11 tempitem.wpn = 0;
8243 11 tempitem.wpn2 = 0;
8244 11 tempitem.wpn3 = 0;
8245 11 tempitem.wpn4 = 0;
8246 11 tempitem.wpn5 = 0;
8247 11 tempitem.wpn6 = 0;
8248 11 tempitem.wpn7 = 0;
8249 11 tempitem.wpn8 = 0;
8250 11 tempitem.wpn9 = 0;
8251 11 tempitem.wpn10 = 0;
8252 11 break;
8253 }
8254 case itype_hammer:
8255 {
8256 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8257 11 tempitem.misc1 = 0;
8258 11 tempitem.misc2 = 0;
8259 11 tempitem.misc3 = 0;
8260 11 tempitem.misc4 = 0;
8261 11 tempitem.misc5 = 0;
8262 11 tempitem.misc6 = 0;
8263 11 tempitem.misc7 = 0;
8264 11 tempitem.misc8 = 0;
8265 11 tempitem.misc9 = 0;
8266 11 tempitem.misc10 = 0;
8267 11 tempitem.wpn3 = 0;
8268 11 tempitem.wpn4 = 0;
8269 11 tempitem.wpn5 = 0;
8270 11 tempitem.wpn6 = 0;
8271 11 tempitem.wpn7 = 0;
8272 11 tempitem.wpn8 = 0;
8273 11 tempitem.wpn9 = 0;
8274 11 tempitem.wpn10 = 0;
8275 11 break;
8276 }
8277 case itype_dinsfire:
8278 {
8279 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8280 11 tempitem.misc3 = 0;
8281 11 tempitem.misc4 = 0;
8282 11 tempitem.misc5 = 0;
8283 11 tempitem.misc6 = 0;
8284 11 tempitem.misc7 = 0;
8285 11 tempitem.misc8 = 0;
8286 11 tempitem.misc9 = 0;
8287 11 tempitem.misc10 = 0;
8288 11 tempitem.wpn6 = 0;
8289 11 tempitem.wpn7 = 0;
8290 11 tempitem.wpn8 = 0;
8291 11 tempitem.wpn9 = 0;
8292 11 tempitem.wpn10 = 0;
8293 11 break;
8294 }
8295 case itype_faroreswind:
8296 {
8297 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8298 11 tempitem.misc2 = 0;
8299 11 tempitem.misc3 = 0;
8300 11 tempitem.misc4 = 0;
8301 11 tempitem.misc5 = 0;
8302 11 tempitem.misc6 = 0;
8303 11 tempitem.misc7 = 0;
8304 11 tempitem.misc8 = 0;
8305 11 tempitem.misc9 = 0;
8306 11 tempitem.misc10 = 0;
8307 11 tempitem.wpn = 0;
8308 11 tempitem.wpn2 = 0;
8309 11 tempitem.wpn3 = 0;
8310 11 tempitem.wpn4 = 0;
8311 11 tempitem.wpn5 = 0;
8312 11 tempitem.wpn6 = 0;
8313 11 tempitem.wpn7 = 0;
8314 11 tempitem.wpn8 = 0;
8315 11 tempitem.wpn9 = 0;
8316 11 tempitem.wpn10 = 0;
8317 11 break;
8318 }
8319 case itype_nayruslove:
8320 {
8321 11 tempitem.flags &= ~ (ITEM_FLAG5);
8322 11 tempitem.misc2 = 0;
8323 11 tempitem.misc3 = 0;
8324 11 tempitem.misc4 = 0;
8325 11 tempitem.misc5 = 0;
8326 11 tempitem.misc6 = 0;
8327 11 tempitem.misc7 = 0;
8328 11 tempitem.misc8 = 0;
8329 11 tempitem.misc9 = 0;
8330 11 tempitem.misc10 = 0;
8331 11 break;
8332 }
8333 case itype_bomb:
8334 {
8335 12 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8336 12 tempitem.misc4 = 0;
8337 12 tempitem.misc5 = 0;
8338 12 tempitem.misc6 = 0;
8339 12 tempitem.misc7 = 0;
8340 12 tempitem.misc8 = 0;
8341 12 tempitem.misc9 = 0;
8342 12 tempitem.misc10 = 0;
8343 12 tempitem.wpn3 = 0;
8344 12 tempitem.wpn4 = 0;
8345 12 tempitem.wpn5 = 0;
8346 12 tempitem.wpn6 = 0;
8347 12 tempitem.wpn7 = 0;
8348 12 tempitem.wpn8 = 0;
8349 12 tempitem.wpn9 = 0;
8350 12 tempitem.wpn10 = 0;
8351 12 break;
8352 }
8353 case itype_sbomb:
8354 {
8355 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8356 11 tempitem.misc4 = 0;
8357 11 tempitem.misc5 = 0;
8358 11 tempitem.misc6 = 0;
8359 11 tempitem.misc7 = 0;
8360 11 tempitem.misc8 = 0;
8361 11 tempitem.misc9 = 0;
8362 11 tempitem.misc10 = 0;
8363 11 tempitem.wpn3 = 0;
8364 11 tempitem.wpn4 = 0;
8365 11 tempitem.wpn5 = 0;
8366 11 tempitem.wpn6 = 0;
8367 11 tempitem.wpn7 = 0;
8368 11 tempitem.wpn8 = 0;
8369 11 tempitem.wpn9 = 0;
8370 11 tempitem.wpn10 = 0;
8371 11 break;
8372 }
8373 case itype_clock:
8374 {
8375 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8376 11 tempitem.misc2 = 0;
8377 11 tempitem.misc3 = 0;
8378 11 tempitem.misc4 = 0;
8379 11 tempitem.misc5 = 0;
8380 11 tempitem.misc6 = 0;
8381 11 tempitem.misc7 = 0;
8382 11 tempitem.misc8 = 0;
8383 11 tempitem.misc9 = 0;
8384 11 tempitem.misc10 = 0;
8385 11 tempitem.wpn = 0;
8386 11 tempitem.wpn2 = 0;
8387 11 tempitem.wpn3 = 0;
8388 11 tempitem.wpn4 = 0;
8389 11 tempitem.wpn5 = 0;
8390 11 tempitem.wpn6 = 0;
8391 11 tempitem.wpn7 = 0;
8392 11 tempitem.wpn8 = 0;
8393 11 tempitem.wpn9 = 0;
8394 11 tempitem.wpn10 = 0;
8395 11 break;
8396 }
8397 case itype_key:
8398 {
8399 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8400 11 tempitem.misc1 = 0;
8401 11 tempitem.misc2 = 0;
8402 11 tempitem.misc3 = 0;
8403 11 tempitem.misc4 = 0;
8404 11 tempitem.misc5 = 0;
8405 11 tempitem.misc6 = 0;
8406 11 tempitem.misc7 = 0;
8407 11 tempitem.misc8 = 0;
8408 11 tempitem.misc9 = 0;
8409 11 tempitem.misc10 = 0;
8410 11 tempitem.wpn = 0;
8411 11 tempitem.wpn2 = 0;
8412 11 tempitem.wpn3 = 0;
8413 11 tempitem.wpn4 = 0;
8414 11 tempitem.wpn5 = 0;
8415 11 tempitem.wpn6 = 0;
8416 11 tempitem.wpn7 = 0;
8417 11 tempitem.wpn8 = 0;
8418 11 tempitem.wpn9 = 0;
8419 11 tempitem.wpn10 = 0;
8420 11 break;
8421 }
8422 case itype_magiccontainer:
8423 {
8424 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8425 11 tempitem.misc1 = 0;
8426 11 tempitem.misc2 = 0;
8427 11 tempitem.misc3 = 0;
8428 11 tempitem.misc4 = 0;
8429 11 tempitem.misc5 = 0;
8430 11 tempitem.misc6 = 0;
8431 11 tempitem.misc7 = 0;
8432 11 tempitem.misc8 = 0;
8433 11 tempitem.misc9 = 0;
8434 11 tempitem.misc10 = 0;
8435 11 tempitem.wpn = 0;
8436 11 tempitem.wpn2 = 0;
8437 11 tempitem.wpn3 = 0;
8438 11 tempitem.wpn4 = 0;
8439 11 tempitem.wpn5 = 0;
8440 11 tempitem.wpn6 = 0;
8441 11 tempitem.wpn7 = 0;
8442 11 tempitem.wpn8 = 0;
8443 11 tempitem.wpn9 = 0;
8444 11 tempitem.wpn10 = 0;
8445 11 break;
8446 }
8447 case itype_triforcepiece:
8448 {
8449 22 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8450 22 tempitem.misc3 = 0;
8451 22 tempitem.misc4 = 0;
8452 22 tempitem.misc5 = 0;
8453 22 tempitem.misc6 = 0;
8454 22 tempitem.misc7 = 0;
8455 22 tempitem.misc8 = 0;
8456 22 tempitem.misc9 = 0;
8457 22 tempitem.misc10 = 0;
8458 22 tempitem.wpn = 0;
8459 22 tempitem.wpn2 = 0;
8460 22 tempitem.wpn3 = 0;
8461 22 tempitem.wpn4 = 0;
8462 22 tempitem.wpn5 = 0;
8463 22 tempitem.wpn6 = 0;
8464 22 tempitem.wpn7 = 0;
8465 22 tempitem.wpn8 = 0;
8466 22 tempitem.wpn9 = 0;
8467 22 tempitem.wpn10 = 0;
8468 22 break;
8469 }
8470 case itype_map: case itype_compass: case itype_bosskey:
8471 {
8472 33 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8473 33 tempitem.misc1 = 0;
8474 33 tempitem.misc2 = 0;
8475 33 tempitem.misc3 = 0;
8476 33 tempitem.misc4 = 0;
8477 33 tempitem.misc5 = 0;
8478 33 tempitem.misc6 = 0;
8479 33 tempitem.misc7 = 0;
8480 33 tempitem.misc8 = 0;
8481 33 tempitem.misc9 = 0;
8482 33 tempitem.misc10 = 0;
8483 33 tempitem.wpn = 0;
8484 33 tempitem.wpn2 = 0;
8485 33 tempitem.wpn3 = 0;
8486 33 tempitem.wpn4 = 0;
8487 33 tempitem.wpn5 = 0;
8488 33 tempitem.wpn6 = 0;
8489 33 tempitem.wpn7 = 0;
8490 33 tempitem.wpn8 = 0;
8491 33 tempitem.wpn9 = 0;
8492 33 tempitem.wpn10 = 0;
8493 33 break;
8494 }
8495 case itype_quiver:
8496 {
8497 44 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8498 44 tempitem.misc3 = 0;
8499 44 tempitem.misc4 = 0;
8500 44 tempitem.misc5 = 0;
8501 44 tempitem.misc6 = 0;
8502 44 tempitem.misc7 = 0;
8503 44 tempitem.misc8 = 0;
8504 44 tempitem.misc9 = 0;
8505 44 tempitem.misc10 = 0;
8506 44 tempitem.wpn = 0;
8507 44 tempitem.wpn2 = 0;
8508 44 tempitem.wpn3 = 0;
8509 44 tempitem.wpn4 = 0;
8510 44 tempitem.wpn5 = 0;
8511 44 tempitem.wpn6 = 0;
8512 44 tempitem.wpn7 = 0;
8513 44 tempitem.wpn8 = 0;
8514 44 tempitem.wpn9 = 0;
8515 44 tempitem.wpn10 = 0;
8516 44 break;
8517 }
8518 case itype_lkey:
8519 {
8520 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8521 11 tempitem.misc1 = 0;
8522 11 tempitem.misc2 = 0;
8523 11 tempitem.misc3 = 0;
8524 11 tempitem.misc4 = 0;
8525 11 tempitem.misc5 = 0;
8526 11 tempitem.misc6 = 0;
8527 11 tempitem.misc7 = 0;
8528 11 tempitem.misc8 = 0;
8529 11 tempitem.misc9 = 0;
8530 11 tempitem.misc10 = 0;
8531 11 tempitem.wpn = 0;
8532 11 tempitem.wpn2 = 0;
8533 11 tempitem.wpn3 = 0;
8534 11 tempitem.wpn4 = 0;
8535 11 tempitem.wpn5 = 0;
8536 11 tempitem.wpn6 = 0;
8537 11 tempitem.wpn7 = 0;
8538 11 tempitem.wpn8 = 0;
8539 11 tempitem.wpn9 = 0;
8540 11 tempitem.wpn10 = 0;
8541 11 break;
8542 }
8543 case itype_cbyrna:
8544 {
8545 11 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8546 11 tempitem.misc4 = 0;
8547 11 tempitem.misc5 = 0;
8548 11 tempitem.misc6 = 0;
8549 11 tempitem.misc7 = 0;
8550 11 tempitem.misc8 = 0;
8551 11 tempitem.misc9 = 0;
8552 11 tempitem.misc10 = 0;
8553 11 tempitem.wpn6 = 0;
8554 11 tempitem.wpn7 = 0;
8555 11 tempitem.wpn8 = 0;
8556 11 tempitem.wpn9 = 0;
8557 11 tempitem.wpn10 = 0;
8558 11 break;
8559 }
8560 case itype_rupee: case itype_arrowammo:
8561 {
8562 127 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8563 127 tempitem.misc1 = 0;
8564 127 tempitem.misc2 = 0;
8565 127 tempitem.misc3 = 0;
8566 127 tempitem.misc4 = 0;
8567 127 tempitem.misc5 = 0;
8568 127 tempitem.misc6 = 0;
8569 127 tempitem.misc7 = 0;
8570 127 tempitem.misc8 = 0;
8571 127 tempitem.misc9 = 0;
8572 127 tempitem.misc10 = 0;
8573 127 tempitem.wpn = 0;
8574 127 tempitem.wpn2 = 0;
8575 127 tempitem.wpn3 = 0;
8576 127 tempitem.wpn4 = 0;
8577 127 tempitem.wpn5 = 0;
8578 127 tempitem.wpn6 = 0;
8579 127 tempitem.wpn7 = 0;
8580 127 tempitem.wpn8 = 0;
8581 127 tempitem.wpn9 = 0;
8582 127 tempitem.wpn10 = 0;
8583 127 break;
8584 }
8585 case itype_fairy:
8586 {
8587 21 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8588 21 tempitem.misc4 = 0;
8589 21 tempitem.misc5 = 0;
8590 21 tempitem.misc6 = 0;
8591 21 tempitem.misc7 = 0;
8592 21 tempitem.misc8 = 0;
8593 21 tempitem.misc9 = 0;
8594 21 tempitem.misc10 = 0;
8595 21 tempitem.wpn = 0;
8596 21 tempitem.wpn2 = 0;
8597 21 tempitem.wpn3 = 0;
8598 21 tempitem.wpn4 = 0;
8599 21 tempitem.wpn5 = 0;
8600 21 tempitem.wpn6 = 0;
8601 21 tempitem.wpn7 = 0;
8602 21 tempitem.wpn8 = 0;
8603 21 tempitem.wpn9 = 0;
8604 21 tempitem.wpn10 = 0;
8605 21 break;
8606 }
8607 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8608 {
8609 113 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8610 113 tempitem.misc1 = 0;
8611 113 tempitem.misc2 = 0;
8612 113 tempitem.misc3 = 0;
8613 113 tempitem.misc4 = 0;
8614 113 tempitem.misc5 = 0;
8615 113 tempitem.misc6 = 0;
8616 113 tempitem.misc7 = 0;
8617 113 tempitem.misc8 = 0;
8618 113 tempitem.misc9 = 0;
8619 113 tempitem.misc10 = 0;
8620 113 tempitem.wpn = 0;
8621 113 tempitem.wpn2 = 0;
8622 113 tempitem.wpn3 = 0;
8623 113 tempitem.wpn4 = 0;
8624 113 tempitem.wpn5 = 0;
8625 113 tempitem.wpn6 = 0;
8626 113 tempitem.wpn7 = 0;
8627 113 tempitem.wpn8 = 0;
8628 113 tempitem.wpn9 = 0;
8629 113 tempitem.wpn10 = 0;
8630 113 break;
8631 }
8632 case itype_bombbag:
8633 {
8634 44 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8635 44 tempitem.misc3 = 0;
8636 44 tempitem.misc4 = 0;
8637 44 tempitem.misc5 = 0;
8638 44 tempitem.misc6 = 0;
8639 44 tempitem.misc7 = 0;
8640 44 tempitem.misc8 = 0;
8641 44 tempitem.misc9 = 0;
8642 44 tempitem.misc10 = 0;
8643 44 tempitem.wpn = 0;
8644 44 tempitem.wpn2 = 0;
8645 44 tempitem.wpn3 = 0;
8646 44 tempitem.wpn4 = 0;
8647 44 tempitem.wpn5 = 0;
8648 44 tempitem.wpn6 = 0;
8649 44 tempitem.wpn7 = 0;
8650 44 tempitem.wpn8 = 0;
8651 44 tempitem.wpn9 = 0;
8652 44 tempitem.wpn10 = 0;
8653 44 break;
8654 }
8655 case itype_rocs:
8656 {
8657 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8658 11 tempitem.misc1 = 0;
8659 11 tempitem.misc2 = 0;
8660 11 tempitem.misc3 = 0;
8661 11 tempitem.misc4 = 0;
8662 11 tempitem.misc5 = 0;
8663 11 tempitem.misc6 = 0;
8664 11 tempitem.misc7 = 0;
8665 11 tempitem.misc8 = 0;
8666 11 tempitem.misc9 = 0;
8667 11 tempitem.misc10 = 0;
8668 11 tempitem.wpn = 0;
8669 11 tempitem.wpn2 = 0;
8670 11 tempitem.wpn3 = 0;
8671 11 tempitem.wpn4 = 0;
8672 11 tempitem.wpn5 = 0;
8673 11 tempitem.wpn6 = 0;
8674 11 tempitem.wpn7 = 0;
8675 11 tempitem.wpn8 = 0;
8676 11 tempitem.wpn9 = 0;
8677 11 tempitem.wpn10 = 0;
8678 11 break;
8679 }
8680 case itype_hoverboots:
8681 {
8682 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8683 11 tempitem.misc2 = 0;
8684 11 tempitem.misc3 = 0;
8685 11 tempitem.misc4 = 0;
8686 11 tempitem.misc5 = 0;
8687 11 tempitem.misc6 = 0;
8688 11 tempitem.misc7 = 0;
8689 11 tempitem.misc8 = 0;
8690 11 tempitem.misc9 = 0;
8691 11 tempitem.misc10 = 0;
8692 11 tempitem.wpn2 = 0;
8693 11 tempitem.wpn3 = 0;
8694 11 tempitem.wpn4 = 0;
8695 11 tempitem.wpn5 = 0;
8696 11 tempitem.wpn6 = 0;
8697 11 tempitem.wpn7 = 0;
8698 11 tempitem.wpn8 = 0;
8699 11 tempitem.wpn9 = 0;
8700 11 tempitem.wpn10 = 0;
8701 11 break;
8702 }
8703 case itype_spinscroll:
8704 {
8705 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8706 11 tempitem.misc2 = 0;
8707 11 tempitem.misc3 = 0;
8708 11 tempitem.misc4 = 0;
8709 11 tempitem.misc5 = 0;
8710 11 tempitem.misc6 = 0;
8711 11 tempitem.misc7 = 0;
8712 11 tempitem.misc8 = 0;
8713 11 tempitem.misc9 = 0;
8714 11 tempitem.misc10 = 0;
8715 11 tempitem.wpn = 0;
8716 11 tempitem.wpn2 = 0;
8717 11 tempitem.wpn3 = 0;
8718 11 tempitem.wpn4 = 0;
8719 11 tempitem.wpn5 = 0;
8720 11 tempitem.wpn6 = 0;
8721 11 tempitem.wpn7 = 0;
8722 11 tempitem.wpn8 = 0;
8723 11 tempitem.wpn9 = 0;
8724 11 tempitem.wpn10 = 0;
8725 11 break;
8726 }
8727 case itype_crossscroll:
8728 {
8729 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8730 11 tempitem.misc1 = 0;
8731 11 tempitem.misc2 = 0;
8732 11 tempitem.misc3 = 0;
8733 11 tempitem.misc4 = 0;
8734 11 tempitem.misc5 = 0;
8735 11 tempitem.misc6 = 0;
8736 11 tempitem.misc7 = 0;
8737 11 tempitem.misc8 = 0;
8738 11 tempitem.misc9 = 0;
8739 11 tempitem.misc10 = 0;
8740 11 tempitem.wpn = 0;
8741 11 tempitem.wpn2 = 0;
8742 11 tempitem.wpn3 = 0;
8743 11 tempitem.wpn4 = 0;
8744 11 tempitem.wpn5 = 0;
8745 11 tempitem.wpn6 = 0;
8746 11 tempitem.wpn7 = 0;
8747 11 tempitem.wpn8 = 0;
8748 11 tempitem.wpn9 = 0;
8749 11 tempitem.wpn10 = 0;
8750 11 break;
8751 }
8752 case itype_quakescroll:
8753 {
8754 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8755 11 tempitem.misc3 = 0;
8756 11 tempitem.misc4 = 0;
8757 11 tempitem.misc5 = 0;
8758 11 tempitem.misc6 = 0;
8759 11 tempitem.misc7 = 0;
8760 11 tempitem.misc8 = 0;
8761 11 tempitem.misc9 = 0;
8762 11 tempitem.misc10 = 0;
8763 11 tempitem.wpn = 0;
8764 11 tempitem.wpn2 = 0;
8765 11 tempitem.wpn3 = 0;
8766 11 tempitem.wpn4 = 0;
8767 11 tempitem.wpn5 = 0;
8768 11 tempitem.wpn6 = 0;
8769 11 tempitem.wpn7 = 0;
8770 11 tempitem.wpn8 = 0;
8771 11 tempitem.wpn9 = 0;
8772 11 tempitem.wpn10 = 0;
8773 11 break;
8774 }
8775 case itype_whispring:
8776 {
8777 22 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8778 22 tempitem.misc2 = 0;
8779 22 tempitem.misc3 = 0;
8780 22 tempitem.misc4 = 0;
8781 22 tempitem.misc5 = 0;
8782 22 tempitem.misc6 = 0;
8783 22 tempitem.misc7 = 0;
8784 22 tempitem.misc8 = 0;
8785 22 tempitem.misc9 = 0;
8786 22 tempitem.misc10 = 0;
8787 22 tempitem.wpn = 0;
8788 22 tempitem.wpn2 = 0;
8789 22 tempitem.wpn3 = 0;
8790 22 tempitem.wpn4 = 0;
8791 22 tempitem.wpn5 = 0;
8792 22 tempitem.wpn6 = 0;
8793 22 tempitem.wpn7 = 0;
8794 22 tempitem.wpn8 = 0;
8795 22 tempitem.wpn9 = 0;
8796 22 tempitem.wpn10 = 0;
8797 22 break;
8798 }
8799 case itype_chargering:
8800 {
8801 22 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8802 22 tempitem.misc3 = 0;
8803 22 tempitem.misc4 = 0;
8804 22 tempitem.misc5 = 0;
8805 22 tempitem.misc6 = 0;
8806 22 tempitem.misc7 = 0;
8807 22 tempitem.misc8 = 0;
8808 22 tempitem.misc9 = 0;
8809 22 tempitem.misc10 = 0;
8810 22 tempitem.wpn = 0;
8811 22 tempitem.wpn2 = 0;
8812 22 tempitem.wpn3 = 0;
8813 22 tempitem.wpn4 = 0;
8814 22 tempitem.wpn5 = 0;
8815 22 tempitem.wpn6 = 0;
8816 22 tempitem.wpn7 = 0;
8817 22 tempitem.wpn8 = 0;
8818 22 tempitem.wpn9 = 0;
8819 22 tempitem.wpn10 = 0;
8820 22 break;
8821 }
8822 case itype_perilscroll:
8823 {
8824 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8825 11 tempitem.misc2 = 0;
8826 11 tempitem.misc3 = 0;
8827 11 tempitem.misc4 = 0;
8828 11 tempitem.misc5 = 0;
8829 11 tempitem.misc6 = 0;
8830 11 tempitem.misc7 = 0;
8831 11 tempitem.misc8 = 0;
8832 11 tempitem.misc9 = 0;
8833 11 tempitem.misc10 = 0;
8834 11 tempitem.wpn = 0;
8835 11 tempitem.wpn2 = 0;
8836 11 tempitem.wpn3 = 0;
8837 11 tempitem.wpn4 = 0;
8838 11 tempitem.wpn5 = 0;
8839 11 tempitem.wpn6 = 0;
8840 11 tempitem.wpn7 = 0;
8841 11 tempitem.wpn8 = 0;
8842 11 tempitem.wpn9 = 0;
8843 11 tempitem.wpn10 = 0;
8844 11 break;
8845 }
8846 case itype_wealthmedal:
8847 {
8848 33 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8849 33 tempitem.misc2 = 0;
8850 33 tempitem.misc3 = 0;
8851 33 tempitem.misc4 = 0;
8852 33 tempitem.misc5 = 0;
8853 33 tempitem.misc6 = 0;
8854 33 tempitem.misc7 = 0;
8855 33 tempitem.misc8 = 0;
8856 33 tempitem.misc9 = 0;
8857 33 tempitem.misc10 = 0;
8858 33 tempitem.wpn = 0;
8859 33 tempitem.wpn2 = 0;
8860 33 tempitem.wpn3 = 0;
8861 33 tempitem.wpn4 = 0;
8862 33 tempitem.wpn5 = 0;
8863 33 tempitem.wpn6 = 0;
8864 33 tempitem.wpn7 = 0;
8865 33 tempitem.wpn8 = 0;
8866 33 tempitem.wpn9 = 0;
8867 33 tempitem.wpn10 = 0;
8868 33 break;
8869 }
8870 case itype_heartring:
8871 {
8872 33 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8873 33 tempitem.misc3 = 0;
8874 33 tempitem.misc4 = 0;
8875 33 tempitem.misc5 = 0;
8876 33 tempitem.misc6 = 0;
8877 33 tempitem.misc7 = 0;
8878 33 tempitem.misc8 = 0;
8879 33 tempitem.misc9 = 0;
8880 33 tempitem.misc10 = 0;
8881 33 tempitem.wpn = 0;
8882 33 tempitem.wpn2 = 0;
8883 33 tempitem.wpn3 = 0;
8884 33 tempitem.wpn4 = 0;
8885 33 tempitem.wpn5 = 0;
8886 33 tempitem.wpn6 = 0;
8887 33 tempitem.wpn7 = 0;
8888 33 tempitem.wpn8 = 0;
8889 33 tempitem.wpn9 = 0;
8890 33 tempitem.wpn10 = 0;
8891 33 break;
8892 }
8893 case itype_magicring:
8894 {
8895 44 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8896 44 tempitem.misc3 = 0;
8897 44 tempitem.misc4 = 0;
8898 44 tempitem.misc5 = 0;
8899 44 tempitem.misc6 = 0;
8900 44 tempitem.misc7 = 0;
8901 44 tempitem.misc8 = 0;
8902 44 tempitem.misc9 = 0;
8903 44 tempitem.misc10 = 0;
8904 44 tempitem.wpn = 0;
8905 44 tempitem.wpn2 = 0;
8906 44 tempitem.wpn3 = 0;
8907 44 tempitem.wpn4 = 0;
8908 44 tempitem.wpn5 = 0;
8909 44 tempitem.wpn6 = 0;
8910 44 tempitem.wpn7 = 0;
8911 44 tempitem.wpn8 = 0;
8912 44 tempitem.wpn9 = 0;
8913 44 tempitem.wpn10 = 0;
8914 44 break;
8915 }
8916 case itype_spinscroll2:
8917 {
8918 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8919 11 tempitem.misc2 = 0;
8920 11 tempitem.misc3 = 0;
8921 11 tempitem.misc4 = 0;
8922 11 tempitem.misc5 = 0;
8923 11 tempitem.misc6 = 0;
8924 11 tempitem.misc7 = 0;
8925 11 tempitem.misc8 = 0;
8926 11 tempitem.misc9 = 0;
8927 11 tempitem.misc10 = 0;
8928 11 tempitem.wpn = 0;
8929 11 tempitem.wpn2 = 0;
8930 11 tempitem.wpn3 = 0;
8931 11 tempitem.wpn4 = 0;
8932 11 tempitem.wpn5 = 0;
8933 11 tempitem.wpn6 = 0;
8934 11 tempitem.wpn7 = 0;
8935 11 tempitem.wpn8 = 0;
8936 11 tempitem.wpn9 = 0;
8937 11 tempitem.wpn10 = 0;
8938 11 break;
8939 }
8940 case itype_quakescroll2:
8941 {
8942 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8943 11 tempitem.misc3 = 0;
8944 11 tempitem.misc4 = 0;
8945 11 tempitem.misc5 = 0;
8946 11 tempitem.misc6 = 0;
8947 11 tempitem.misc7 = 0;
8948 11 tempitem.misc8 = 0;
8949 11 tempitem.misc9 = 0;
8950 11 tempitem.misc10 = 0;
8951 11 tempitem.wpn = 0;
8952 11 tempitem.wpn2 = 0;
8953 11 tempitem.wpn3 = 0;
8954 11 tempitem.wpn4 = 0;
8955 11 tempitem.wpn5 = 0;
8956 11 tempitem.wpn6 = 0;
8957 11 tempitem.wpn7 = 0;
8958 11 tempitem.wpn8 = 0;
8959 11 tempitem.wpn9 = 0;
8960 11 tempitem.wpn10 = 0;
8961 11 break;
8962 }
8963 case itype_agony:
8964 {
8965 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8966 11 tempitem.misc2 = 0;
8967 11 tempitem.misc3 = 0;
8968 11 tempitem.misc4 = 0;
8969 11 tempitem.misc5 = 0;
8970 11 tempitem.misc6 = 0;
8971 11 tempitem.misc7 = 0;
8972 11 tempitem.misc8 = 0;
8973 11 tempitem.misc9 = 0;
8974 11 tempitem.misc10 = 0;
8975 11 tempitem.wpn = 0;
8976 11 tempitem.wpn2 = 0;
8977 11 tempitem.wpn3 = 0;
8978 11 tempitem.wpn4 = 0;
8979 11 tempitem.wpn5 = 0;
8980 11 tempitem.wpn6 = 0;
8981 11 tempitem.wpn7 = 0;
8982 11 tempitem.wpn8 = 0;
8983 11 tempitem.wpn9 = 0;
8984 11 tempitem.wpn10 = 0;
8985 11 break;
8986 }
8987 case itype_stompboots:
8988 {
8989 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8990 11 tempitem.misc1 = 0;
8991 11 tempitem.misc2 = 0;
8992 11 tempitem.misc3 = 0;
8993 11 tempitem.misc4 = 0;
8994 11 tempitem.misc5 = 0;
8995 11 tempitem.misc6 = 0;
8996 11 tempitem.misc7 = 0;
8997 11 tempitem.misc8 = 0;
8998 11 tempitem.misc9 = 0;
8999 11 tempitem.misc10 = 0;
9000 11 tempitem.wpn = 0;
9001 11 tempitem.wpn2 = 0;
9002 11 tempitem.wpn3 = 0;
9003 11 tempitem.wpn4 = 0;
9004 11 tempitem.wpn5 = 0;
9005 11 tempitem.wpn6 = 0;
9006 11 tempitem.wpn7 = 0;
9007 11 tempitem.wpn8 = 0;
9008 11 tempitem.wpn9 = 0;
9009 11 tempitem.wpn10 = 0;
9010 11 break;
9011 }
9012 case itype_whimsicalring:
9013 {
9014 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9015 11 tempitem.misc2 = 0;
9016 11 tempitem.misc3 = 0;
9017 11 tempitem.misc4 = 0;
9018 11 tempitem.misc5 = 0;
9019 11 tempitem.misc6 = 0;
9020 11 tempitem.misc7 = 0;
9021 11 tempitem.misc8 = 0;
9022 11 tempitem.misc9 = 0;
9023 11 tempitem.misc10 = 0;
9024 11 tempitem.wpn = 0;
9025 11 tempitem.wpn2 = 0;
9026 11 tempitem.wpn3 = 0;
9027 11 tempitem.wpn4 = 0;
9028 11 tempitem.wpn5 = 0;
9029 11 tempitem.wpn6 = 0;
9030 11 tempitem.wpn7 = 0;
9031 11 tempitem.wpn8 = 0;
9032 11 tempitem.wpn9 = 0;
9033 11 tempitem.wpn10 = 0;
9034 11 break;
9035 }
9036 case itype_perilring:
9037 {
9038 11 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9039 11 tempitem.misc2 = 0;
9040 11 tempitem.misc3 = 0;
9041 11 tempitem.misc4 = 0;
9042 11 tempitem.misc5 = 0;
9043 11 tempitem.misc6 = 0;
9044 11 tempitem.misc7 = 0;
9045 11 tempitem.misc8 = 0;
9046 11 tempitem.misc9 = 0;
9047 11 tempitem.misc10 = 0;
9048 11 tempitem.wpn = 0;
9049 11 tempitem.wpn2 = 0;
9050 11 tempitem.wpn3 = 0;
9051 11 tempitem.wpn4 = 0;
9052 11 tempitem.wpn5 = 0;
9053 11 tempitem.wpn6 = 0;
9054 11 tempitem.wpn7 = 0;
9055 11 tempitem.wpn8 = 0;
9056 11 tempitem.wpn9 = 0;
9057 11 tempitem.wpn10 = 0;
9058 11 break;
9059 }
9060 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9061 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9062 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9063 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9064 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9065 {
9066 986 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9067 986 tempitem.misc1 = 0;
9068 986 tempitem.misc2 = 0;
9069 986 tempitem.misc3 = 0;
9070 986 tempitem.misc4 = 0;
9071 986 tempitem.misc5 = 0;
9072 986 tempitem.misc6 = 0;
9073 986 tempitem.misc7 = 0;
9074 986 tempitem.misc8 = 0;
9075 986 tempitem.misc9 = 0;
9076 986 tempitem.misc10 = 0;
9077 986 tempitem.wpn = 0;
9078 986 tempitem.wpn2 = 0;
9079 986 tempitem.wpn3 = 0;
9080 986 tempitem.wpn4 = 0;
9081 986 tempitem.wpn5 = 0;
9082 986 tempitem.wpn6 = 0;
9083 986 tempitem.wpn7 = 0;
9084 986 tempitem.wpn8 = 0;
9085 986 tempitem.wpn9 = 0;
9086 986 tempitem.wpn10 = 0;
9087 986 break;
9088 }
9089 }
9090 2816 }
9091 //Port quest rules to items
9092
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if( s_version <= 31)
9093 {
9094
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2804 times.
2816 if(tempitem.family == itype_bomb)
9095 {
9096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9097 12 else tempitem.flags &= ~ ITEM_FLAG2;
9098 12 }
9099
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2793 times.
2804 else if(tempitem.family == itype_sbomb)
9100 {
9101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9102 11 else tempitem.flags &= ~ ITEM_FLAG2;
9103 11 }
9104
9105
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 2760 times.
2793 else if(tempitem.family == itype_brang)
9106 {
9107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if ( get_bit(quest_rules,qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9108 33 else tempitem.flags &= ~ ITEM_FLAG4;
9109 33 }
9110
2/2
✓ Branch 0 taken 2748 times.
✓ Branch 1 taken 12 times.
2760 else if(tempitem.family == itype_wand)
9111 {
9112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if ( get_bit(quest_rules,qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9113 12 else tempitem.flags &= ~ ITEM_FLAG3;
9114 12 }
9115 2816 }
9116
9117 //Port quest rules to items
9118
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if( s_version <= 37)
9119 {
9120
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2805 times.
2816 if(tempitem.family == itype_flippers)
9121 {
9122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( (get_bit(quest_rules,qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9123 11 else tempitem.flags &= ~ ITEM_FLAG1;
9124 11 }
9125
2/2
✓ Branch 0 taken 2463 times.
✓ Branch 1 taken 342 times.
2805 else if(tempitem.family == itype_sword)
9126 {
9127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 342 times.
342 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9128 342 else tempitem.flags &= ~ ITEM_FLAG5;
9129 342 }
9130
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2451 times.
2463 else if(tempitem.family == itype_wand)
9131 {
9132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9133 12 else tempitem.flags &= ~ ITEM_FLAG5;
9134 12 }
9135
4/4
✓ Branch 0 taken 2439 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 2415 times.
2451 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9136 {
9137 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9138
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 33 times.
36 if ( (get_bit(quest_rules,qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9139 33 else tempitem.flags &= ~ ITEM_FLAG3;
9140 36 }
9141 2816 }
9142
9143
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if( s_version < 38)
9144 {
9145
4/4
✓ Branch 0 taken 2783 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 2761 times.
2816 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9146 {
9147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9148 55 else tempitem.flags &= ~ITEM_FLAG4;
9149
9150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9151 55 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9152 55 }
9153
2/2
✓ Branch 0 taken 2728 times.
✓ Branch 1 taken 33 times.
2761 else if(tempitem.family == itype_arrow)
9154 {
9155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9156 33 else tempitem.flags &= ~ITEM_FLAG4;
9157
9158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9159 33 else tempitem.flags |= ITEM_FLAG2;
9160 33 }
9161 2816 }
9162
9163
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if( s_version < 39)
9164 {
9165
6/6
✓ Branch 0 taken 2805 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2793 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 2769 times.
2816 if(tempitem.family == itype_dinsfire || tempitem.family == itype_book || tempitem.family == itype_candle)
9166 {
9167
1/2
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
47 if(get_bit(quest_rules,qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9168 47 else tempitem.flags &= ~ITEM_FLAG5;
9169 47 }
9170
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2747 times.
2769 else if(tempitem.family == itype_potion)
9171 {
9172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(get_bit(quest_rules,qr_NONBUBBLEMEDICINE))
9173 {
9174 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9175 }
9176 else
9177 {
9178 22 tempitem.flags |= ITEM_FLAG3;
9179
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 18 times.
22 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9180 18 else tempitem.flags &= ~ITEM_FLAG4;
9181 }
9182 22 }
9183
2/2
✓ Branch 0 taken 2725 times.
✓ Branch 1 taken 22 times.
2747 else if(tempitem.family == itype_triforcepiece)
9184 {
9185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(get_bit(quest_rules,qr_NONBUBBLETRIFORCE))
9186 {
9187 tempitem.flags |= ITEM_FLAG3;
9188 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9189 else tempitem.flags &= ~ITEM_FLAG4;
9190 }
9191 else
9192 {
9193 22 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9194 }
9195 22 }
9196 2816 }
9197
9198
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if( s_version < 40)
9199 {
9200
4/4
✓ Branch 0 taken 2783 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 2772 times.
2816 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9201 {
9202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(get_bit(quest_rules,qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9203 44 else tempitem.flags &= ~ITEM_FLAG1;
9204 44 }
9205
8/8
✓ Branch 0 taken 2748 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 2406 times.
✓ Branch 3 taken 342 times.
✓ Branch 4 taken 2394 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 11 times.
✓ Branch 7 taken 2383 times.
2772 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9206 {
9207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 389 times.
389 if(get_bit(quest_rules,qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9208 389 else tempitem.flags &= ~ITEM_FLAG8;
9209 389 }
9210
6/6
✓ Branch 0 taken 2474 times.
✓ Branch 1 taken 342 times.
✓ Branch 2 taken 2462 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 2451 times.
2816 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9211 {
9212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 365 times.
365 if(get_bit(quest_rules,qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9213 365 else tempitem.flags &= ~ITEM_FLAG7;
9214 365 }
9215
2/2
✓ Branch 0 taken 2440 times.
✓ Branch 1 taken 11 times.
2451 else if(tempitem.family == itype_cbyrna)
9216 {
9217 11 tempitem.flags |= ITEM_FLAG7;
9218 11 }
9219 2816 }
9220
9221
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if( s_version < 41 )
9222 {
9223
2/2
✓ Branch 0 taken 2474 times.
✓ Branch 1 taken 342 times.
2816 if(tempitem.family == itype_sword)
9224 {
9225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 342 times.
342 if(get_bit(quest_rules,qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9226 342 else tempitem.flags &= ~ITEM_FLAG9;
9227
9228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 342 times.
342 if(get_bit(quest_rules,qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9229 342 else tempitem.flags &= ~ITEM_FLAG10;
9230 342 }
9231 2816 }
9232
9233
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if( s_version < 42 )
9234 {
9235
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2804 times.
2816 if(tempitem.family == itype_wand)
9236 {
9237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(get_bit(quest_rules,qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9238 12 else tempitem.flags &= ~ITEM_FLAG3;
9239
9240 12 tempitem.flags &= ~ITEM_FLAG6;
9241 12 }
9242
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2793 times.
2804 else if(tempitem.family == itype_hammer)
9243 {
9244 11 tempitem.flags &= ~ITEM_FLAG3;
9245 11 }
9246
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2782 times.
2793 else if(tempitem.family == itype_cbyrna)
9247 {
9248 11 tempitem.flags |= ITEM_FLAG3;
9249
9250 11 tempitem.flags &= ~ITEM_FLAG6;
9251 11 }
9252
2/2
✓ Branch 0 taken 2440 times.
✓ Branch 1 taken 342 times.
2782 else if(tempitem.family == itype_sword)
9253 {
9254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 342 times.
342 if(get_bit(quest_rules,qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9255 342 else tempitem.flags &= ~ITEM_FLAG6;
9256 342 }
9257 2816 }
9258
9259
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if( s_version < 43 )
9260 {
9261
2/2
✓ Branch 0 taken 2803 times.
✓ Branch 1 taken 13 times.
2816 if(tempitem.family == itype_whistle)
9262 {
9263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(get_bit(quest_rules,qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9264 13 else tempitem.flags &= ~ITEM_FLAG3;
9265 13 }
9266 2816 }
9267
9268
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if( s_version < 45 )
9269 {
9270
2/2
✓ Branch 0 taken 2805 times.
✓ Branch 1 taken 11 times.
2816 if(tempitem.family == itype_flippers)
9271 {
9272 11 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9273 11 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9274 11 }
9275 2816 }
9276
9277
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if( s_version < 46 )
9278 {
9279
2/2
✓ Branch 0 taken 2805 times.
✓ Branch 1 taken 11 times.
2816 if(tempitem.family == itype_raft)
9280 {
9281 11 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9282 11 }
9283 2816 }
9284
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if ( s_version < 34 ) //! set the default counter for older quests.
9285 {
9286
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2805 times.
2816 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9287 {
9288 11 tempitem.cost_counter[0] = 1;
9289 11 }
9290 else
9291 {
9292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2805 times.
2805 if(get_bit(quest_rules,qr_ENABLEMAGIC))
9293 tempitem.cost_counter[0] = 4;
9294 else
9295 {
9296 2805 tempitem.cost_amount[0] = 0;
9297 2805 tempitem.cost_counter[0] = -1;
9298 }
9299 }
9300 2816 }
9301
9302
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if ( s_version < 35 ) //new Lens of Truth flags
9303 {
9304
2/2
✓ Branch 0 taken 2805 times.
✓ Branch 1 taken 11 times.
2816 if ( tempitem.family == itype_lens )
9305 {
9306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( get_bit(quest_rules,qr_RAFTLENS) )
9307 {
9308 tempitem.flags |= ITEM_FLAG4;
9309 }
9310
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 9 times.
11 if ( get_bit(quest_rules,qr_LENSHINTS) )
9311 {
9312 2 tempitem.flags |= ITEM_FLAG1;
9313 2 }
9314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( get_bit(quest_rules,qr_LENSSEESENEMIES) )
9315 {
9316 tempitem.flags |= ITEM_FLAG5;
9317 }
9318 11 }
9319 2816 }
9320
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9321 {
9322
2/2
✓ Branch 0 taken 22528 times.
✓ Branch 1 taken 2816 times.
25344 for ( int32_t q = 0; q < 8; q++ )
9323 {
9324 22528 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9325 22528 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9326 22528 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9327 22528 tempitem.sprite_initiald[q] = 0;
9328 22528 }
9329
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 2816 times.
8448 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9330 2816 tempitem.sprite_script = 0;
9331 2816 }
9332
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9333 {
9334 2816 tempitem.pickupflag = 0;
9335 2816 }
9336
9337
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if( s_version < 51 )
9338 {
9339
2/2
✓ Branch 0 taken 2792 times.
✓ Branch 1 taken 24 times.
2816 if( tempitem.family == itype_candle )
9340 {
9341 24 tempitem.misc4 = 50; //Step speed
9342 24 }
9343 2816 }
9344
9345
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if( s_version < 52 )
9346 {
9347
2/2
✓ Branch 0 taken 2783 times.
✓ Branch 1 taken 33 times.
2816 if( tempitem.family == itype_shield )
9348 33 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9349 2816 }
9350
9351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
3328 if(tempitem.fam_type==0) // Always do this
9352 tempitem.fam_type=1;
9353
9354 3328 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9355 3328 }
9356 13 }
9357
9358 13 return 0;
9359 13 }
9360
9361 static bool did_init_def_items = false;
9362 6656 void init_def_items()
9363 {
9364
2/2
✓ Branch 0 taken 6645 times.
✓ Branch 1 taken 11 times.
6656 if(did_init_def_items) return;
9365 11 did_init_def_items = true;
9366 11 default_items[3].cost_counter[1] = crBOMBS;
9367 11 default_items[13].cost_counter[1] = crARROWS;
9368 11 default_items[14].cost_counter[1] = crARROWS;
9369 11 default_items[48].cost_counter[1] = crBOMBS;
9370 11 default_items[57].cost_counter[1] = crARROWS;
9371 6656 }
9372 6656 void reset_itembuf(itemdata *item, int32_t id)
9373 {
9374 6656 init_def_items();
9375
2/2
✓ Branch 0 taken 2938 times.
✓ Branch 1 taken 3718 times.
6656 if(id<iLast)
9376 {
9377 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9378 3718 word tile = item->tile;
9379 3718 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9380 3718 int32_t ltm = item->ltm;
9381
9382 3718 memcpy(item,&default_items[id],sizeof(itemdata));
9383 3718 item->tile = tile;
9384 3718 item->misc_flags = miscs;
9385 3718 item->csets = cset;
9386 3718 item->frames = frames;
9387 3718 item->speed = speed;
9388 3718 item->delay = delay;
9389 3718 item->ltm = ltm;
9390 3718 }
9391 6656 }
9392
9393 2816 void reset_itemname(int32_t id)
9394 {
9395 2816 sprintf(item_string[id],"zz%03d",id);
9396
9397
2/2
✓ Branch 0 taken 1243 times.
✓ Branch 1 taken 1573 times.
2816 if(id < iLast)
9398 1573 strcpy(item_string[id],old_item_string[id]);
9399 2816 }
9400
9401 13 int32_t readweapons(PACKFILE *f, zquestheader *Header, bool keepdata)
9402 {
9403 13 word weapons_to_read=MAXWPNS;
9404 int32_t dummy;
9405 byte padding;
9406 wpndata tempweapon;
9407 13 word s_version=0, s_cversion=0;
9408
9409
9410
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Header->zelda_version < 0x186)
9411 {
9412 weapons_to_read=64;
9413 }
9414
9415
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Header->zelda_version < 0x185)
9416 {
9417 weapons_to_read=32;
9418 }
9419
9420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(Header->zelda_version > 0x192)
9421 {
9422 13 weapons_to_read=0;
9423
9424 //section version info
9425
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_version,f,true))
9426 {
9427 return qe_invalid;
9428 }
9429
9430 13 FFCore.quest_format[vWeaponSprites] = s_version;
9431
9432 //al_trace("Weapons version %d\n", s_version);
9433
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_cversion,f,true))
9434 {
9435 return qe_invalid;
9436 }
9437
9438 //section size
9439
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy,f,true))
9440 {
9441 return qe_invalid;
9442 }
9443
9444 //finally... section data
9445
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&weapons_to_read,f,true))
9446 {
9447 return qe_invalid;
9448 }
9449 13 }
9450
9451
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version>2)
9452 {
9453
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<weapons_to_read; i++)
9454 {
9455 char tempname[64];
9456
9457
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!pfread(tempname, 64, f, keepdata))
9458 {
9459 return qe_invalid;
9460 }
9461
9462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
3328 if(keepdata)
9463 {
9464 3328 strcpy(weapon_string[i], tempname);
9465 3328 }
9466 3328 }
9467
9468
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version<4)
9469 {
9470 if(keepdata)
9471 {
9472 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9473 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9474 }
9475 }
9476
9477
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version<5)
9478 {
9479 if(keepdata)
9480 {
9481 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9482 }
9483 }
9484
9485 /*
9486 if (s_version<6)
9487 {
9488 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9489 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9490 }
9491 */
9492 13 }
9493 else
9494 {
9495 if(keepdata)
9496 for(int32_t i=0; i<WPNCNT; i++)
9497 reset_weaponname(i);
9498 }
9499
9500
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<weapons_to_read; i++)
9501 {
9502 3328 word oldtile = 0;
9503
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if (s_version < 8)
9504 {
9505
1/2
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
2816 if (!p_igetw(&oldtile, f, true))
9506 return qe_invalid;
9507 2816 }
9508
9509
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempweapon.misc,f,true))
9510 {
9511 return qe_invalid;
9512 }
9513
9514
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempweapon.csets,f,true))
9515 {
9516 return qe_invalid;
9517 }
9518
9519
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempweapon.frames,f,true))
9520 {
9521 return qe_invalid;
9522 }
9523
9524
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempweapon.speed,f,true))
9525 {
9526 return qe_invalid;
9527 }
9528
9529
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(!p_getc(&tempweapon.type,f,true))
9530 {
9531 return qe_invalid;
9532 }
9533
9534
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 512 times.
3328 if ( s_version >= 7 )
9535 {
9536
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetw(&tempweapon.script,f,true))
9537 {
9538 return qe_invalid;
9539 }
9540
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_igetl(&tempweapon.tile,f,true))
9541 {
9542 return qe_invalid;
9543 }
9544 512 }
9545
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2816 times.
3328 if ( s_version < 7 )
9546 {
9547 2816 tempweapon.tile = oldtile;
9548 2816 }
9549
9550
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(Header->zelda_version < 0x193)
9551 {
9552 if(!p_getc(&padding,f,true))
9553 {
9554 return qe_invalid;
9555 }
9556 }
9557
9558
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(s_version < 6)
9559 {
9560 if(i==ewFIRETRAIL)
9561 {
9562 tempweapon.misc |= WF_BEHIND;
9563 }
9564 else
9565 tempweapon.misc &= ~WF_BEHIND;
9566 }
9567
9568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
3328 if(keepdata==true)
9569 {
9570 3328 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9571 3328 }
9572 3328 }
9573
9574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata==true)
9575 {
9576
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version<2)
9577 {
9578 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9579 }
9580
9581
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version<5)
9582 {
9583 wpnsbuf[iwQuarterHearts].tile=1;
9584 wpnsbuf[iwQuarterHearts].csets=1;
9585 }
9586
9587
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Header->zelda_version < 0x176)
9588 {
9589 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9590 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9591 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9592 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9593 }
9594
9595
1/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if((Header->zelda_version < 0x192)||
9596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9597 {
9598 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9599 }
9600
9601
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if((Header->zelda_version < 0x210))
9602 {
9603 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9604 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9605 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9606 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9607 }
9608 13 }
9609
9610 13 return 0;
9611 13 }
9612
9613 13 void init_guys(int32_t guyversion)
9614 {
9615
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 13 times.
6669 for(int32_t i=0; i<MAXGUYS; i++)
9616 {
9617 6656 guysbuf[i] = default_guys[0];
9618 6656 }
9619
9620
2/2
✓ Branch 0 taken 2301 times.
✓ Branch 1 taken 13 times.
2314 for(int32_t i=0; i<OLDMAXGUYS; i++)
9621 {
9622 2301 guysbuf[i] = default_guys[i];
9623
2/2
✓ Branch 0 taken 2275 times.
✓ Branch 1 taken 26 times.
2301 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9624 2301 guysbuf[i].spr_death = iwDeath;
9625 2301 guysbuf[i].spr_spawn = iwSpawn;
9626 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9627
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2301 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2301 if(guyversion<=3 && i==ePATRABS)
9628 {
9629 guysbuf[i].bosspal=spDIG;
9630 guysbuf[i].cset=14;
9631 guysbuf[i].misc9=14;
9632 }
9633
9634
1/2
✓ Branch 0 taken 2301 times.
✗ Branch 1 not taken.
2301 if(guyversion<=3)
9635 {
9636 // Rope/Ghini Flash rules
9637 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9638 {
9639 if(i==eROPE2)
9640 {
9641 guysbuf[i].flags2 &= ~guy_flashing;
9642 }
9643 }
9644
9645 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9646 {
9647 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9648 {
9649 guysbuf[i].flags2 &= ~guy_flashing;
9650 }
9651 }
9652
9653 if(i==eGHINI2)
9654 {
9655 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9656 {
9657 guysbuf[i].flags2 |= guy_blinking;
9658 }
9659
9660 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9661 {
9662 guysbuf[i].flags2 |= guy_transparent;
9663 }
9664 }
9665 }
9666
9667 // Darknut fix
9668
10/10
✓ Branch 0 taken 2288 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 2275 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 2262 times.
✓ Branch 5 taken 13 times.
✓ Branch 6 taken 2249 times.
✓ Branch 7 taken 13 times.
✓ Branch 8 taken 13 times.
✓ Branch 9 taken 2236 times.
2301 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9669 {
9670
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 45 times.
65 if(get_bit(quest_rules,qr_NEWENEMYTILES))
9671 {
9672 20 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9673 20 guysbuf[i].s_width=guysbuf[i].e_width;
9674 20 guysbuf[i].s_height=guysbuf[i].e_height;
9675 20 }
9676 45 else guysbuf[i].s_tile=860;
9677
9678
1/2
✓ Branch 0 taken 65 times.
✗ Branch 1 not taken.
65 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9679 {
9680 guysbuf[i].flags |= guy_bkshield;
9681 }
9682 65 }
9683
9684
3/4
✓ Branch 0 taken 2288 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 2301 times.
✗ Branch 3 not taken.
2301 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9685 {
9686 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9687 }
9688 2301 }
9689 13 }
9690
9691 void reset_weaponname(int32_t i)
9692 {
9693 if(i<wLast)
9694 {
9695 strcpy(weapon_string[i],old_weapon_string[i]);
9696 }
9697 else
9698 sprintf(weapon_string[i],"zz%03d",i);
9699 }
9700
9701 13 void init_item_drop_sets()
9702 {
9703
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9704 {
9705 // item_drop_sets[i] = default_item_drop_sets[0];
9706 3328 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9707 3328 }
9708
9709
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 13 times.
182 for(int32_t i=0; i<isMAX; i++)
9710 {
9711 169 item_drop_sets[i] = default_item_drop_sets[i];
9712
9713 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9714
2/2
✓ Branch 0 taken 1690 times.
✓ Branch 1 taken 169 times.
1859 for(int32_t j=0; j<10; ++j)
9715 {
9716 1690 int32_t it = item_drop_sets[i].item[j];
9717
9718
3/4
✓ Branch 0 taken 1196 times.
✓ Branch 1 taken 494 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 78 times.
1690 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9719
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 1118 times.
1196 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9720 {
9721 78 item_drop_sets[i].chance[j+1]=0;
9722 78 }
9723
3/4
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 1560 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52 times.
1612 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9724 {
9725 item_drop_sets[i].chance[j+1]=0;
9726 }
9727
9728 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9729
1/2
✓ Branch 0 taken 1690 times.
✗ Branch 1 not taken.
1690 if(itemsbuf[it].family == itype_misc)
9730 {
9731 // If a non-gameplay item was selected, then item drop was aborted.
9732 // Reflect this by increasing the 'Nothing' chance accordingly.
9733 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9734 item_drop_sets[i].chance[j+1]=0;
9735 }
9736 1690 }
9737 169 }
9738 13 }
9739
9740 13 void init_favorites()
9741 {
9742
2/2
✓ Branch 0 taken 1300 times.
✓ Branch 1 taken 13 times.
1313 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9743 {
9744 1300 favorite_combos[i]=-1;
9745 1300 }
9746
9747
2/2
✓ Branch 0 taken 1300 times.
✓ Branch 1 taken 13 times.
1313 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9748 {
9749 1300 favorite_comboaliases[i]=-1;
9750 1300 }
9751 13 }
9752
9753 const char *ctype_name[cMAX]=
9754 {
9755 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9756 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9757 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9758 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9759 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9760 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9761 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9762 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9763 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9764 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9765 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9766 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9767 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9768 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9769 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9770 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9771 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9772 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9773 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9774 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9775 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9776 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9777 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9778 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9779 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9780 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9781 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9782 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9783
9784 };
9785
9786 24 int32_t init_combo_classes()
9787 {
9788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9789
2/2
✓ Branch 0 taken 4272 times.
✓ Branch 1 taken 24 times.
4296 for(int32_t i=0; i<cMAX; i++)
9790 {
9791 4272 combo_class_buf[i] = default_combo_classes[i];
9792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4272 times.
4272 if ( char const* nm = zi->getComboTypeName(i) )
9793 {
9794 4272 size_t len = strlen(nm);
9795
2/2
✓ Branch 0 taken 273408 times.
✓ Branch 1 taken 4272 times.
277680 for ( size_t q = 0; q < 64; q++ )
9796 {
9797
2/2
✓ Branch 0 taken 63312 times.
✓ Branch 1 taken 210096 times.
273408 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9798 273408 }
9799 4272 }
9800 4272 }
9801
9802 24 return 0;
9803 }
9804
9805 11 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
9806 {
9807
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 assert(v_herosprites < 6);
9808 //these are here to bypass compiler warnings about unused arguments
9809 11 cv_herosprites=cv_herosprites;
9810
9811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(keepdata)
9812 {
9813 11 zinit.hero_swim_speed=67; //default
9814 11 setupherotiles(zinit.heroAnimationStyle);
9815 11 setupherodefenses();
9816 11 setupherooffsets();
9817 11 }
9818
9819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(v_herosprites>=0)
9820 {
9821 word tile, tile2;
9822 byte flip, extend, dummy_byte;
9823
9824
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<4; i++)
9825 {
9826
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_igetw(&tile,f,keepdata))
9827 {
9828 return qe_invalid;
9829 }
9830
9831
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&flip,f,keepdata))
9832 {
9833 return qe_invalid;
9834 }
9835
9836
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&extend,f,keepdata))
9837 {
9838 return qe_invalid;
9839 }
9840
9841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(keepdata)
9842 {
9843 44 walkspr[i][spr_tile]=(int32_t)tile;
9844 44 walkspr[i][spr_flip]=(int32_t)flip;
9845 44 walkspr[i][spr_extend]=(int32_t)extend;
9846 44 }
9847 44 }
9848
9849
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<4; i++)
9850 {
9851
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_igetw(&tile,f,keepdata))
9852 {
9853 return qe_invalid;
9854 }
9855
9856
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&flip,f,keepdata))
9857 {
9858 return qe_invalid;
9859 }
9860
9861
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&extend,f,keepdata))
9862 {
9863 return qe_invalid;
9864 }
9865
9866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(keepdata)
9867 {
9868 44 stabspr[i][spr_tile]=(int32_t)tile;
9869 44 stabspr[i][spr_flip]=(int32_t)flip;
9870 44 stabspr[i][spr_extend]=(int32_t)extend;
9871 44 }
9872 44 }
9873
9874
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<4; i++)
9875 {
9876
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_igetw(&tile,f,keepdata))
9877 {
9878 return qe_invalid;
9879 }
9880
9881
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&flip,f,keepdata))
9882 {
9883 return qe_invalid;
9884 }
9885
9886
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&extend,f,keepdata))
9887 {
9888 return qe_invalid;
9889 }
9890
9891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(keepdata)
9892 {
9893 44 slashspr[i][spr_tile]=(int32_t)tile;
9894 44 slashspr[i][spr_flip]=(int32_t)flip;
9895 44 slashspr[i][spr_extend]=(int32_t)extend;
9896 44 }
9897 44 }
9898
9899
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<4; i++)
9900 {
9901
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_igetw(&tile,f,keepdata))
9902 {
9903 return qe_invalid;
9904 }
9905
9906
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&flip,f,keepdata))
9907 {
9908 return qe_invalid;
9909 }
9910
9911
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&extend,f,keepdata))
9912 {
9913 return qe_invalid;
9914 }
9915
9916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(keepdata)
9917 {
9918 44 floatspr[i][spr_tile]=(int32_t)tile;
9919 44 floatspr[i][spr_flip]=(int32_t)flip;
9920 44 floatspr[i][spr_extend]=(int32_t)extend;
9921 44 }
9922 44 }
9923
9924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(v_herosprites>1)
9925 {
9926
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<4; i++)
9927 {
9928
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_igetw(&tile,f,keepdata))
9929 {
9930 return qe_invalid;
9931 }
9932
9933
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&flip,f,keepdata))
9934 {
9935 return qe_invalid;
9936 }
9937
9938
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&extend,f,keepdata))
9939 {
9940 return qe_invalid;
9941 }
9942
9943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(keepdata)
9944 {
9945 44 swimspr[i][spr_tile]=(int32_t)tile;
9946 44 swimspr[i][spr_flip]=(int32_t)flip;
9947 44 swimspr[i][spr_extend]=(int32_t)extend;
9948 44 }
9949 44 }
9950 11 }
9951
9952
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<4; i++)
9953 {
9954
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_igetw(&tile,f,keepdata))
9955 {
9956 return qe_invalid;
9957 }
9958
9959
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&flip,f,keepdata))
9960 {
9961 return qe_invalid;
9962 }
9963
9964
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&extend,f,keepdata))
9965 {
9966 return qe_invalid;
9967 }
9968
9969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(keepdata)
9970 {
9971 44 divespr[i][spr_tile]=(int32_t)tile;
9972 44 divespr[i][spr_flip]=(int32_t)flip;
9973 44 divespr[i][spr_extend]=(int32_t)extend;
9974 44 }
9975 44 }
9976
9977
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<4; i++)
9978 {
9979
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_igetw(&tile,f,keepdata))
9980 {
9981 return qe_invalid;
9982 }
9983
9984
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&flip,f,keepdata))
9985 {
9986 return qe_invalid;
9987 }
9988
9989
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&extend,f,keepdata))
9990 {
9991 return qe_invalid;
9992 }
9993
9994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(keepdata)
9995 {
9996 44 poundspr[i][spr_tile]=(int32_t)tile;
9997 44 poundspr[i][spr_flip]=(int32_t)flip;
9998 44 poundspr[i][spr_extend]=(int32_t)extend;
9999 44 }
10000 44 }
10001
10002
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetw(&tile,f,keepdata))
10003 {
10004 return qe_invalid;
10005 }
10006
10007 11 flip=0;
10008
10009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(v_herosprites>0)
10010 {
10011
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&flip,f,keepdata))
10012 {
10013 return qe_invalid;
10014 }
10015 11 }
10016
10017
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&extend,f,keepdata))
10018 {
10019 return qe_invalid;
10020 }
10021
10022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(keepdata)
10023 {
10024 11 castingspr[spr_tile]=(int32_t)tile;
10025 11 castingspr[spr_flip]=(int32_t)flip;
10026 11 castingspr[spr_extend]=(int32_t)extend;
10027 11 }
10028
10029
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(v_herosprites>0)
10030 {
10031 11 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10032
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 11 times.
33 for(int32_t i=0; i<2; i++)
10033 {
10034
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 22 times.
66 for(int32_t j=0; j<num_holdsprs; j++)
10035 {
10036
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_igetw(&tile,f,keepdata))
10037 {
10038 return qe_invalid;
10039 }
10040
10041
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&flip,f,keepdata))
10042 {
10043 return qe_invalid;
10044 }
10045
10046
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&extend,f,keepdata))
10047 {
10048 return qe_invalid;
10049 }
10050
10051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(keepdata)
10052 {
10053 44 holdspr[i][j][spr_tile]=(int32_t)tile;
10054 44 holdspr[i][j][spr_flip]=(int32_t)flip;
10055 44 holdspr[i][j][spr_extend]=(int32_t)extend;
10056 44 }
10057 44 }
10058 22 }
10059 11 }
10060 else
10061 {
10062 for(int32_t i=0; i<2; i++)
10063 {
10064 if(!p_igetw(&tile,f,keepdata))
10065 {
10066 return qe_invalid;
10067 }
10068
10069 if(!p_igetw(&tile2,f,keepdata))
10070 {
10071 return qe_invalid;
10072 }
10073
10074 if(!p_getc(&extend,f,keepdata))
10075 {
10076 return qe_invalid;
10077 }
10078
10079 if(keepdata)
10080 {
10081 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10082 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10083 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10084 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10085 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10086 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10087 }
10088 }
10089 }
10090
10091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(v_herosprites>2)
10092 {
10093
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<4; i++)
10094 {
10095
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_igetw(&tile,f,keepdata))
10096 {
10097 return qe_invalid;
10098 }
10099
10100
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&flip,f,keepdata))
10101 {
10102 return qe_invalid;
10103 }
10104
10105
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&extend,f,keepdata))
10106 {
10107 return qe_invalid;
10108 }
10109
10110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(keepdata)
10111 {
10112 44 jumpspr[i][spr_tile]=(int32_t)tile;
10113 44 jumpspr[i][spr_flip]=(int32_t)flip;
10114 44 jumpspr[i][spr_extend]=(int32_t)extend;
10115 44 }
10116 44 }
10117 11 }
10118
10119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(v_herosprites>3)
10120 {
10121
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<4; i++)
10122 {
10123
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_igetw(&tile,f,keepdata))
10124 {
10125 return qe_invalid;
10126 }
10127
10128
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&flip,f,keepdata))
10129 {
10130 return qe_invalid;
10131 }
10132
10133
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(!p_getc(&extend,f,keepdata))
10134 {
10135 return qe_invalid;
10136 }
10137
10138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(keepdata)
10139 {
10140 44 chargespr[i][spr_tile]=(int32_t)tile;
10141 44 chargespr[i][spr_flip]=(int32_t)flip;
10142 44 chargespr[i][spr_extend]=(int32_t)extend;
10143 44 }
10144 44 }
10145 11 }
10146
10147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(v_herosprites>4)
10148 {
10149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!p_getc(&dummy_byte,f,keepdata))
10150 {
10151 return qe_invalid;
10152 }
10153
10154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(keepdata)
10155 {
10156 11 zinit.hero_swim_speed=(byte)dummy_byte;
10157 11 }
10158 11 }
10159
10160
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(keepdata)
10161 {
10162 11 memset(frozenspr, 0, sizeof(frozenspr));
10163 11 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10164 11 memset(onfirespr, 0, sizeof(onfirespr));
10165 11 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10166 11 memset(diggingspr, 0, sizeof(diggingspr));
10167 11 memset(usingrodspr, 0, sizeof(usingrodspr));
10168 11 memset(usingcanespr, 0, sizeof(usingcanespr));
10169 11 memset(pushingspr, 0, sizeof(pushingspr));
10170 11 memset(liftingspr, 0, sizeof(liftingspr));
10171 11 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10172 11 memset(stunnedspr, 0, sizeof(stunnedspr));
10173 11 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10174 11 memset(fallingspr, 0, sizeof(fallingspr));
10175 11 memset(shockedspr, 0, sizeof(shockedspr));
10176 11 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10177 11 memset(pullswordspr, 0, sizeof(pullswordspr));
10178 11 memset(readingspr, 0, sizeof(readingspr));
10179 11 memset(slash180spr, 0, sizeof(slash180spr));
10180 11 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10181 11 memset(dashspr, 0, sizeof(dashspr));
10182 11 memset(bonkspr, 0, sizeof(bonkspr));
10183 11 memset(medallionsprs, 0, sizeof(medallionsprs));
10184 11 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10185 11 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10186
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t q = 0; q < 4; ++q)
10187 {
10188
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 44 times.
176 for(int32_t p = 0; p < 3; ++p)
10189 {
10190 132 drowningspr[q][p] = divespr[q][p];
10191 132 drowning_lavaspr[q][p] = divespr[q][p];
10192 132 }
10193 44 }
10194 11 memset(sideswimspr, 0, sizeof(sideswimspr));
10195 11 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10196 11 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10197 11 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10198 11 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10199 11 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10200 11 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10201 11 }
10202 11 }
10203
10204 11 return 0;
10205 11 }
10206
10207 340 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10208 {
10209 340 arr[spr_tile] = tile;
10210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 arr[spr_flip] = (flip > 3 ? 0 : flip);
10211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 arr[spr_extend] = (ext > 2 ? 0 : ext);
10212 340 }
10213 //Used to read the player sprites as int32_t, not word.
10214 2 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
10215 {
10216 //these are here to bypass compiler warnings about unused arguments
10217 2 cv_herosprites=cv_herosprites;
10218
10219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(keepdata)
10220 {
10221 2 zinit.hero_swim_speed=67; //default
10222 2 setupherotiles(zinit.heroAnimationStyle);
10223 2 setupherodefenses();
10224 2 setupherooffsets();
10225 2 }
10226
10227 int32_t tile, tile2;
10228 byte flip, extend, dummy_byte;
10229
10230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(v_herosprites>=0)
10231 {
10232
10233
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t i=0; i<4; i++)
10234 {
10235
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10236 {
10237 return qe_invalid;
10238 }
10239
10240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
10241 {
10242 return qe_invalid;
10243 }
10244
10245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10246 {
10247 return qe_invalid;
10248 }
10249
10250 8 if(keepdata)
10251 {
10252 8 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10253 8 }
10254 8 }
10255
10256
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t i=0; i<4; i++)
10257 {
10258
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10259 {
10260 return qe_invalid;
10261 }
10262
10263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
10264 {
10265 return qe_invalid;
10266 }
10267
10268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10269 {
10270 return qe_invalid;
10271 }
10272
10273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10274 {
10275 8 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10276 8 }
10277 8 }
10278
10279
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t i=0; i<4; i++)
10280 {
10281
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10282 {
10283 return qe_invalid;
10284 }
10285
10286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
10287 {
10288 return qe_invalid;
10289 }
10290
10291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10292 {
10293 return qe_invalid;
10294 }
10295
10296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10297 {
10298 8 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10299 8 }
10300 8 }
10301
10302
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t i=0; i<4; i++)
10303 {
10304
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10305 {
10306 return qe_invalid;
10307 }
10308
10309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
10310 {
10311 return qe_invalid;
10312 }
10313
10314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10315 {
10316 return qe_invalid;
10317 }
10318
10319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10320 {
10321 8 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10322 8 }
10323 8 }
10324
10325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(v_herosprites>1)
10326 {
10327
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t i=0; i<4; i++)
10328 {
10329
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10330 {
10331 return qe_invalid;
10332 }
10333
10334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
10335 {
10336 return qe_invalid;
10337 }
10338
10339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10340 {
10341 return qe_invalid;
10342 }
10343
10344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10345 {
10346 8 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10347 8 }
10348 8 }
10349 2 }
10350
10351
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t i=0; i<4; i++)
10352 {
10353
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10354 {
10355 return qe_invalid;
10356 }
10357
10358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
10359 {
10360 return qe_invalid;
10361 }
10362
10363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10364 {
10365 return qe_invalid;
10366 }
10367
10368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10369 {
10370 8 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10371 8 }
10372 8 }
10373
10374
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t i=0; i<4; i++)
10375 {
10376
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10377 {
10378 return qe_invalid;
10379 }
10380
10381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
10382 {
10383 return qe_invalid;
10384 }
10385
10386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10387 {
10388 return qe_invalid;
10389 }
10390
10391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10392 {
10393 8 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10394 8 }
10395 8 }
10396
10397
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetl(&tile,f,keepdata))
10398 {
10399 return qe_invalid;
10400 }
10401
10402 2 flip=0;
10403
10404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(v_herosprites>0)
10405 {
10406
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&flip,f,keepdata))
10407 {
10408 return qe_invalid;
10409 }
10410 2 }
10411
10412
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&extend,f,keepdata))
10413 {
10414 return qe_invalid;
10415 }
10416
10417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(keepdata)
10418 {
10419 2 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10420 2 }
10421
10422
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(v_herosprites>0)
10423 {
10424 2 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10425
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 for(int32_t i=0; i<2; i++)
10426 {
10427
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 for(int32_t j=0; j<num_holdsprs; j++)
10428 {
10429
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetl(&tile,f,keepdata))
10430 {
10431 return qe_invalid;
10432 }
10433
10434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&flip,f,keepdata))
10435 {
10436 return qe_invalid;
10437 }
10438
10439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!p_getc(&extend,f,keepdata))
10440 {
10441 return qe_invalid;
10442 }
10443
10444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(keepdata)
10445 {
10446 12 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10447 12 }
10448 12 }
10449 4 }
10450 2 }
10451 else
10452 {
10453 for(int32_t i=0; i<2; i++)
10454 {
10455 if(!p_igetl(&tile,f,keepdata))
10456 {
10457 return qe_invalid;
10458 }
10459
10460 if(!p_igetl(&tile2,f,keepdata))
10461 {
10462 return qe_invalid;
10463 }
10464
10465 if(!p_getc(&extend,f,keepdata))
10466 {
10467 return qe_invalid;
10468 }
10469
10470 if(keepdata)
10471 {
10472 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10473 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10474 }
10475 }
10476 }
10477
10478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(v_herosprites>2)
10479 {
10480
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t i=0; i<4; i++)
10481 {
10482
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10483 {
10484 return qe_invalid;
10485 }
10486
10487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
10488 {
10489 return qe_invalid;
10490 }
10491
10492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10493 {
10494 return qe_invalid;
10495 }
10496
10497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10498 {
10499 8 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10500 8 }
10501 8 }
10502 2 }
10503
10504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(v_herosprites>3)
10505 {
10506
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t i=0; i<4; i++)
10507 {
10508
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10509 {
10510 return qe_invalid;
10511 }
10512
10513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
10514 {
10515 return qe_invalid;
10516 }
10517
10518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10519 {
10520 return qe_invalid;
10521 }
10522
10523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10524 {
10525 8 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10526 8 }
10527 8 }
10528 2 }
10529
10530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(v_herosprites>4)
10531 {
10532
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&dummy_byte,f,keepdata))
10533 {
10534 return qe_invalid;
10535 }
10536
10537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(keepdata)
10538 {
10539 2 zinit.hero_swim_speed=(byte)dummy_byte;
10540 2 }
10541 2 }
10542
10543
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(v_herosprites>6)
10544 {
10545
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10546 {
10547
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10548 return qe_invalid;
10549
10550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
10551 return qe_invalid;
10552
10553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10554 return qe_invalid;
10555
10556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10557 {
10558 8 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10559 8 }
10560 8 }
10561
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10562 {
10563
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10564 return qe_invalid;
10565
10566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
10567 return qe_invalid;
10568
10569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10570 return qe_invalid;
10571
10572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10573 {
10574 8 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10575 8 }
10576 8 }
10577
10578
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10579 {
10580
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10581 return qe_invalid;
10582
10583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
10584 return qe_invalid;
10585
10586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10587 return qe_invalid;
10588
10589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10590 {
10591 8 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10592 8 }
10593 8 }
10594
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10595 {
10596
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10597 return qe_invalid;
10598
10599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
10600 return qe_invalid;
10601
10602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10603 return qe_invalid;
10604
10605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10606 {
10607 8 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10608 8 }
10609 8 }
10610
10611
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10612 {
10613
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10614 return qe_invalid;
10615
10616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
10617 return qe_invalid;
10618
10619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10620 return qe_invalid;
10621
10622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10623 {
10624 8 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10625 8 }
10626 8 }
10627
10628
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10629 {
10630
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10631 return qe_invalid;
10632
10633
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&flip,f,keepdata))
10634 return qe_invalid;
10635
10636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10637 return qe_invalid;
10638
10639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10640 {
10641 8 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10642 8 }
10643 8 }
10644
10645
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10646 {
10647
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10648 return qe_invalid;
10649
10650
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&flip,f,keepdata))
10651 return qe_invalid;
10652
10653
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&extend,f,keepdata))
10654 return qe_invalid;
10655
10656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10657 {
10658 8 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10659 8 }
10660 8 }
10661
10662
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10663 {
10664
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10665 return qe_invalid;
10666
10667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
10668 return qe_invalid;
10669
10670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10671 return qe_invalid;
10672
10673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10674 {
10675 8 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10676 8 }
10677 8 }
10678
10679
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10680 {
10681
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10682 return qe_invalid;
10683
10684
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&flip,f,keepdata))
10685 return qe_invalid;
10686
10687
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&extend,f,keepdata))
10688 return qe_invalid;
10689
10690 8 byte frames = 0;
10691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(v_herosprites > 15)
10692 {
10693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&frames,f,keepdata))
10694 return qe_invalid;
10695 8 }
10696
10697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10698 {
10699 8 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10700 8 liftingspr[q][spr_frames] = frames;
10701 8 }
10702 8 }
10703
10704
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10705 {
10706
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10707 return qe_invalid;
10708
10709
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&flip,f,keepdata))
10710 return qe_invalid;
10711
10712
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&extend,f,keepdata))
10713 return qe_invalid;
10714
10715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10716 {
10717 8 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10718 8 }
10719 8 }
10720
10721
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10722 {
10723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_igetl(&tile,f,keepdata))
10724 return qe_invalid;
10725
10726
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&flip,f,keepdata))
10727 return qe_invalid;
10728
10729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10730 return qe_invalid;
10731
10732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10733 {
10734 8 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10735 8 }
10736 8 }
10737
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10738 {
10739
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10740 return qe_invalid;
10741
10742
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&flip,f,keepdata))
10743 return qe_invalid;
10744
10745
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&extend,f,keepdata))
10746 return qe_invalid;
10747
10748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10749 {
10750 8 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10751 8 }
10752 8 }
10753
10754
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10755 {
10756
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10757 return qe_invalid;
10758
10759
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&flip,f,keepdata))
10760 return qe_invalid;
10761
10762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10763 return qe_invalid;
10764
10765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10766 {
10767 8 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10768 8 }
10769 8 }
10770
10771
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10772 {
10773
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10774 return qe_invalid;
10775
10776
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&flip,f,keepdata))
10777 return qe_invalid;
10778
10779
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&extend,f,keepdata))
10780 return qe_invalid;
10781
10782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10783 {
10784 8 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10785 8 }
10786 8 }
10787
10788
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10789 {
10790
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10791 return qe_invalid;
10792
10793
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&flip,f,keepdata))
10794 return qe_invalid;
10795
10796
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&extend,f,keepdata))
10797 return qe_invalid;
10798
10799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10800 {
10801 8 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10802 8 }
10803 8 }
10804
10805
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10806 {
10807
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10808 return qe_invalid;
10809
10810
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&flip,f,keepdata))
10811 return qe_invalid;
10812
10813
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&extend,f,keepdata))
10814 return qe_invalid;
10815
10816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10817 {
10818 8 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10819 8 }
10820 8 }
10821
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10822 {
10823
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10824 return qe_invalid;
10825
10826
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&flip,f,keepdata))
10827 return qe_invalid;
10828
10829
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&extend,f,keepdata))
10830 return qe_invalid;
10831
10832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10833 {
10834 8 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10835 8 }
10836 8 }
10837
10838
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10839 {
10840
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10841 return qe_invalid;
10842
10843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
10844 return qe_invalid;
10845
10846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10847 return qe_invalid;
10848
10849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10850 {
10851 8 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10852 8 }
10853 8 }
10854
10855
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10856 {
10857
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10858 return qe_invalid;
10859
10860
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&flip,f,keepdata))
10861 return qe_invalid;
10862
10863
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&extend,f,keepdata))
10864 return qe_invalid;
10865
10866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10867 {
10868 8 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10869 8 }
10870 8 }
10871
10872
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10873 {
10874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_igetl(&tile,f,keepdata))
10875 return qe_invalid;
10876
10877
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&flip,f,keepdata))
10878 return qe_invalid;
10879
10880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
10881 return qe_invalid;
10882
10883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10884 {
10885 8 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10886 8 }
10887 8 }
10888
10889
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10890 {
10891
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10892 return qe_invalid;
10893
10894
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&flip,f,keepdata))
10895 return qe_invalid;
10896
10897
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&extend,f,keepdata))
10898 return qe_invalid;
10899
10900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10901 {
10902 8 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10903 8 }
10904 8 }
10905
10906
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10907 {
10908
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10909 return qe_invalid;
10910
10911
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&flip,f,keepdata))
10912 return qe_invalid;
10913
10914
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&extend,f,keepdata))
10915 return qe_invalid;
10916
10917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10918 {
10919 8 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10920 8 }
10921 8 }
10922
10923
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10924 {
10925
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10926 return qe_invalid;
10927
10928
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&flip,f,keepdata))
10929 return qe_invalid;
10930
10931
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&extend,f,keepdata))
10932 return qe_invalid;
10933
10934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
10935 {
10936 8 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10937 8 }
10938 8 }
10939
10940
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10941 {
10942
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_igetl(&tile,f,keepdata))
10943 return qe_invalid;
10944
10945
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&flip,f,keepdata))
10946 return qe_invalid;
10947
10948
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&extend,f,keepdata))
10949 return qe_invalid;
10950
10951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(keepdata)
10952 {
10953 6 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10954 6 }
10955 6 }
10956 2 }
10957 else if(keepdata)
10958 {
10959 memset(frozenspr, 0, sizeof(frozenspr));
10960 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10961 memset(onfirespr, 0, sizeof(onfirespr));
10962 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10963 memset(diggingspr, 0, sizeof(diggingspr));
10964 memset(usingrodspr, 0, sizeof(usingrodspr));
10965 memset(usingcanespr, 0, sizeof(usingcanespr));
10966 memset(pushingspr, 0, sizeof(pushingspr));
10967 memset(liftingspr, 0, sizeof(liftingspr));
10968 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10969 memset(stunnedspr, 0, sizeof(stunnedspr));
10970 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10971 memset(fallingspr, 0, sizeof(fallingspr));
10972 memset(shockedspr, 0, sizeof(shockedspr));
10973 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10974 memset(pullswordspr, 0, sizeof(pullswordspr));
10975 memset(readingspr, 0, sizeof(readingspr));
10976 memset(slash180spr, 0, sizeof(slash180spr));
10977 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10978 memset(dashspr, 0, sizeof(dashspr));
10979 memset(bonkspr, 0, sizeof(bonkspr));
10980 memset(medallionsprs, 0, sizeof(medallionsprs));
10981 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10982 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10983 for(int32_t q = 0; q < 4; ++q)
10984 {
10985 for(int32_t p = 0; p < 3; ++p)
10986 {
10987 drowningspr[q][p] = divespr[q][p];
10988 drowning_lavaspr[q][p] = divespr[q][p];
10989 }
10990 }
10991 }
10992
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (v_herosprites > 8)
10993 {
10994
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
10995 {
10996
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
10997 return qe_invalid;
10998
10999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
11000 return qe_invalid;
11001
11002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
11003 return qe_invalid;
11004
11005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
11006 {
11007 8 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11008 8 }
11009 8 }
11010 2 }
11011 else if (keepdata)
11012 {
11013 memset(sideswimspr, 0, sizeof(sideswimspr));
11014 }
11015
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (v_herosprites > 9)
11016 {
11017
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
11018 {
11019
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
11020 return qe_invalid;
11021
11022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
11023 return qe_invalid;
11024
11025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
11026 return qe_invalid;
11027
11028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
11029 {
11030 8 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11031 8 }
11032 8 }
11033
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
11034 {
11035
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
11036 return qe_invalid;
11037
11038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
11039 return qe_invalid;
11040
11041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
11042 return qe_invalid;
11043
11044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
11045 {
11046 8 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11047 8 }
11048 8 }
11049
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
11050 {
11051
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
11052 return qe_invalid;
11053
11054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
11055 return qe_invalid;
11056
11057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
11058 return qe_invalid;
11059
11060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
11061 {
11062 8 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11063 8 }
11064 8 }
11065
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
11066 {
11067
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
11068 return qe_invalid;
11069
11070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
11071 return qe_invalid;
11072
11073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
11074 return qe_invalid;
11075
11076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
11077 {
11078 8 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11079 8 }
11080 8 }
11081 2 }
11082 else if (keepdata)
11083 {
11084 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11085 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11086 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11087 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11088 }
11089
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (v_herosprites > 10)
11090 {
11091
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
11092 {
11093 int32_t hmr;
11094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_igetl(&hmr,f,keepdata))
11095 return qe_invalid;
11096
11097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
11098 {
11099 8 hammeroffsets[q] = hmr;
11100 8 }
11101 8 }
11102 2 }
11103 else if (keepdata)
11104 {
11105 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11106 }
11107
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (v_herosprites > 11)
11108 {
11109
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 for(int32_t q = 0; q < 3; ++q)
11110 {
11111
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_igetl(&tile,f,keepdata))
11112 return qe_invalid;
11113
11114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!p_getc(&flip,f,keepdata))
11115 return qe_invalid;
11116
11117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!p_getc(&extend,f,keepdata))
11118 return qe_invalid;
11119
11120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(keepdata)
11121 {
11122 6 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11123 6 }
11124 6 }
11125 2 }
11126 else if (keepdata)
11127 {
11128 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11129 }
11130
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (v_herosprites > 12)
11131 {
11132
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetl(&tile,f,keepdata))
11133 return qe_invalid;
11134
11135
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&flip,f,keepdata))
11136 return qe_invalid;
11137
11138
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&extend,f,keepdata))
11139 return qe_invalid;
11140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (keepdata)
11141 {
11142 2 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11143 2 }
11144
11145 2 }
11146 else if (keepdata)
11147 {
11148 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11149 }
11150
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (v_herosprites > 13)
11151 {
11152
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
11153 {
11154
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
11155 return qe_invalid;
11156
11157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
11158 return qe_invalid;
11159
11160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
11161 return qe_invalid;
11162
11163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
11164 {
11165 8 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11166 8 }
11167 8 }
11168 2 }
11169 else if (keepdata)
11170 {
11171 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11172 }
11173
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (v_herosprites > 14)
11174 {
11175
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t q = 0; q < 4; ++q)
11176 {
11177
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetl(&tile,f,keepdata))
11178 return qe_invalid;
11179
11180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&flip,f,keepdata))
11181 return qe_invalid;
11182
11183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&extend,f,keepdata))
11184 return qe_invalid;
11185
11186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(keepdata)
11187 {
11188 8 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11189 8 }
11190 8 }
11191 2 }
11192 else if (keepdata)
11193 {
11194 memset(revslashspr, 0, sizeof(revslashspr));
11195 }
11196
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (v_herosprites > 7)
11197 {
11198 2 int32_t num_defense = wMax;
11199 2 byte def = 0;
11200
11201 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11202 /*if(v_herosprites > [x])
11203 * {
11204 * num_defense = 146 //value of wMax on version 8
11205 * }
11206 */
11207
11208
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 2 times.
294 for (int32_t q = 0; q < num_defense; q++)
11209 {
11210
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if (!p_getc(&def, f, keepdata))
11211 return qe_invalid;
11212
11213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
292 if (keepdata)
11214 {
11215 292 hero_defence[q] = def;
11216 292 }
11217 292 }
11218 2 }
11219 else if (keepdata)
11220 {
11221 int32_t num_defense = wMax;
11222 for (int32_t q = 0; q < num_defense; q++)
11223 {
11224 hero_defence[q] = 0;
11225 }
11226 }
11227 2 }
11228
11229 2 return 0;
11230 2 }
11231
11232
11233 13 int32_t readherosprites(PACKFILE *f, zquestheader *Header, bool keepdata)
11234 {
11235 //these are here to bypass compiler warnings about unused arguments
11236 13 Header=Header;
11237
11238 dword dummy;
11239 13 word s_version=0, s_cversion=0;
11240
11241 //section version info
11242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!p_igetw(&s_version,f,true))
11243 {
11244 return qe_invalid;
11245 }
11246
11247 13 FFCore.quest_format[vHeroSprites] = s_version;
11248
11249 //al_trace("Player sprites version %d\n", s_version);
11250
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_cversion,f,true))
11251 {
11252 return qe_invalid;
11253 }
11254
11255 //section size
11256
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy,f,true))
11257 {
11258 return qe_invalid;
11259 }
11260
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if ( s_version >= 6 )
11261 {
11262 //al_trace("Reading Player Sprites v6\n");
11263 2 return readherosprites3(f, s_version, dummy, keepdata);
11264 }
11265 11 else return readherosprites2(f, s_version, dummy, keepdata);
11266 13 }
11267
11268 13 int32_t readsubscreens(PACKFILE *f, zquestheader *Header, bool keepdata)
11269 {
11270 int32_t dummy;
11271 13 word s_version=0, s_cversion=0;
11272
11273 //section version info
11274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!p_igetw(&s_version,f,true))
11275 {
11276 return qe_invalid;
11277 }
11278
11279 13 FFCore.quest_format[vSubscreen] = s_version;
11280
11281 //al_trace("Subscreens version %d\n", s_version);
11282
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_cversion,f,true))
11283 {
11284 return qe_invalid;
11285 }
11286
11287 //section size
11288
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy,f,true))
11289 {
11290 return qe_invalid;
11291 }
11292
11293 //finally... section data
11294
2/2
✓ Branch 0 taken 1664 times.
✓ Branch 1 taken 13 times.
1677 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11295 {
11296 1664 int32_t ret = read_one_subscreen(f, Header, keepdata, i, s_version, s_cversion);
11297
11298
1/2
✓ Branch 0 taken 1664 times.
✗ Branch 1 not taken.
1664 if(ret!=0) return ret;
11299 1664 }
11300
11301 13 return 0;
11302 13 }
11303
11304 1664 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, bool keepdata, int32_t i, word s_version, word)
11305 {
11306 1664 int32_t numsub=0;
11307 1664 byte temp_ss=0;
11308 subscreen_object temp_sub_stack;
11309 1664 subscreen_object *temp_sub = &temp_sub_stack;
11310
11311 char tempname[64];
11312
11313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1664 times.
1664 if(!pfread(tempname,64,f,true))
11314 {
11315 return qe_invalid;
11316 }
11317
11318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1664 times.
1664 if(s_version > 1)
11319 {
11320
1/2
✓ Branch 0 taken 1664 times.
✗ Branch 1 not taken.
1664 if(!p_getc(&temp_ss,f,keepdata))
11321 {
11322 return qe_invalid;
11323 }
11324 1664 }
11325
11326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1664 times.
1664 if(s_version < 4)
11327 {
11328 uint8_t tmp=0;
11329
11330 if(!p_getc(&tmp,f,true))
11331 {
11332 return qe_invalid;
11333 }
11334
11335 numsub = (int32_t)tmp;
11336 }
11337 else
11338 {
11339 word tmp;
11340
11341
1/2
✓ Branch 0 taken 1664 times.
✗ Branch 1 not taken.
1664 if(!p_igetw(&tmp, f, true))
11342 {
11343 return qe_invalid;
11344 }
11345
11346 1664 numsub = (int32_t)tmp;
11347 }
11348
11349 int32_t j;
11350
11351
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3733 times.
✓ Branch 2 taken 2069 times.
✓ Branch 3 taken 1664 times.
3733 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11352 {
11353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2069 times.
2069 if(keepdata)
11354 {
11355 2069 memset(temp_sub,0,sizeof(subscreen_object));
11356
11357
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 1953 times.
2069 switch(custom_subscreen[i].objects[j].type)
11358 {
11359 case ssoTEXT:
11360 case ssoTEXTBOX:
11361 case ssoCURRENTITEMTEXT:
11362 case ssoCURRENTITEMCLASSTEXT:
11363
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
116 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11364
11365 //fall through
11366 default:
11367 2069 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11368 2069 break;
11369 }
11370 2069 }
11371
11372
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_getc(&(temp_sub->type),f,true))
11373 {
11374 return qe_invalid;
11375 }
11376
11377
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_getc(&(temp_sub->pos),f,keepdata))
11378 {
11379 return qe_invalid;
11380 }
11381
11382
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(s_version < 5)
11383 {
11384 switch(temp_sub->pos)
11385 {
11386 case 0:
11387 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11388 break;
11389
11390 case 1:
11391 temp_sub->pos = sspUP;
11392 break;
11393
11394 case 2:
11395 temp_sub->pos = sspDOWN;
11396 break;
11397
11398 default:
11399 temp_sub->pos = 0;
11400 }
11401 }
11402
11403
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetw(&(temp_sub->x),f,keepdata))
11404 {
11405 return qe_invalid;
11406 }
11407
11408
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetw(&(temp_sub->y),f,keepdata))
11409 {
11410 return qe_invalid;
11411 }
11412
11413
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetw(&(temp_sub->w),f,keepdata))
11414 {
11415 return qe_invalid;
11416 }
11417
11418
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetw(&(temp_sub->h),f,keepdata))
11419 {
11420 return qe_invalid;
11421 }
11422
11423
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_getc(&(temp_sub->colortype1),f,keepdata))
11424 {
11425 return qe_invalid;
11426 }
11427
11428
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetw(&(temp_sub->color1),f,keepdata))
11429 {
11430 return qe_invalid;
11431 }
11432
11433
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_getc(&(temp_sub->colortype2),f,keepdata))
11434 {
11435 return qe_invalid;
11436 }
11437
11438
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetw(&(temp_sub->color2),f,keepdata))
11439 {
11440 return qe_invalid;
11441 }
11442
11443
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_getc(&(temp_sub->colortype3),f,keepdata))
11444 {
11445 return qe_invalid;
11446 }
11447
11448
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetw(&(temp_sub->color3),f,keepdata))
11449 {
11450 return qe_invalid;
11451 }
11452
11453
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetd(&(temp_sub->d1),f,keepdata))
11454 {
11455 return qe_invalid;
11456 }
11457
11458
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetd(&(temp_sub->d2),f,keepdata))
11459 {
11460 return qe_invalid;
11461 }
11462
11463
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetd(&(temp_sub->d3),f,keepdata))
11464 {
11465 return qe_invalid;
11466 }
11467
11468
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetd(&(temp_sub->d4),f,keepdata))
11469 {
11470 return qe_invalid;
11471 }
11472
11473
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetd(&(temp_sub->d5),f,keepdata))
11474 {
11475 return qe_invalid;
11476 }
11477
11478
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetd(&(temp_sub->d6),f,keepdata))
11479 {
11480 return qe_invalid;
11481 }
11482
11483
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetd(&(temp_sub->d7),f,keepdata))
11484 {
11485 return qe_invalid;
11486 }
11487
11488
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetd(&(temp_sub->d8),f,keepdata))
11489 {
11490 return qe_invalid;
11491 }
11492
11493
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetd(&(temp_sub->d9),f,keepdata))
11494 {
11495 return qe_invalid;
11496 }
11497
11498
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetd(&(temp_sub->d10),f,keepdata))
11499 {
11500 return qe_invalid;
11501 }
11502
11503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2069 times.
2069 if(s_version < 2)
11504 {
11505 if(!p_igetl(&(temp_sub->speed),f,keepdata))
11506 {
11507 return qe_invalid;
11508 }
11509
11510 if(!p_igetl(&(temp_sub->delay),f,keepdata))
11511 {
11512 return qe_invalid;
11513 }
11514
11515 if(!p_igetl(&(temp_sub->frame),f,keepdata))
11516 {
11517 return qe_invalid;
11518 }
11519 }
11520 else
11521 {
11522
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_getc(&(temp_sub->speed),f,keepdata))
11523 {
11524 return qe_invalid;
11525 }
11526
11527
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_getc(&(temp_sub->delay),f,keepdata))
11528 {
11529 return qe_invalid;
11530 }
11531
11532
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!p_igetw(&(temp_sub->frame),f,keepdata))
11533 {
11534 return qe_invalid;
11535 }
11536 }
11537
11538 2069 int32_t temp_size=0;
11539
11540 // bool deletets = false;
11541
4/4
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 209 times.
✓ Branch 2 taken 977 times.
✓ Branch 3 taken 22 times.
2069 switch(temp_sub->type)
11542 {
11543 case ssoTEXT:
11544 case ssoTEXTBOX:
11545 case ssoCURRENTITEMTEXT:
11546 case ssoCURRENTITEMCLASSTEXT:
11547 word temptempsize;
11548 /*uint8_t temp1;
11549 uint8_t temp2;
11550 temp2 = 0;
11551 if(!p_getc(&temp1,f,true))
11552 {
11553 return qe_invalid;
11554 }
11555 if(temp1)
11556 {
11557
11558 if(!p_getc(&temp2,f,true))
11559 {
11560 return qe_invalid;
11561 }
11562 }*/
11563
11564
1/2
✓ Branch 0 taken 209 times.
✗ Branch 1 not taken.
209 if(!p_igetw(&temptempsize,f,true))
11565 {
11566 return qe_invalid;
11567 }
11568
11569 //temptempsize = temp1 + (temp2 << 8);
11570 209 temp_size = (int32_t)temptempsize;
11571
11572 //if(temp_sub->dp1!=NULL) delete[] temp_sub->dp1;
11573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209 times.
209 if(keepdata)
11574 {
11575 209 uint32_t char_length = temp_size+1;
11576 209 temp_sub->dp1 = new char[char_length]; //memory not freed
11577
11578 //deletets = true; //obsolete
11579 209 }
11580
11581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209 times.
209 if(temp_size)
11582 {
11583
1/2
✓ Branch 0 taken 209 times.
✗ Branch 1 not taken.
209 if(!pfread(temp_sub->dp1,temp_size+1,f,keepdata))
11584 {
11585 return qe_invalid;
11586 }
11587 209 }
11588
11589 209 break;
11590
11591 case ssoLIFEMETER:
11592
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11593 temp_sub->d3 = 1;
11594
11595
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11596 {
11597 return qe_invalid;
11598 }
11599
11600 22 break;
11601
11602
11603 case ssoCURRENTITEM:
11604
11605
1/2
✓ Branch 0 taken 861 times.
✗ Branch 1 not taken.
861 if(s_version < 6)
11606 {
11607 switch(temp_sub->d1)
11608 {
11609 case ssiBOMB:
11610 temp_sub->d1 = itype_bomb;
11611 break;
11612
11613 case ssiSWORD:
11614 temp_sub->d1 = itype_sword;
11615 break;
11616
11617 case ssiSHIELD:
11618 temp_sub->d1 = itype_shield;
11619 break;
11620
11621 case ssiCANDLE:
11622 temp_sub->d1 = itype_candle;
11623 break;
11624
11625 case ssiLETTER:
11626 temp_sub->d1 = itype_letter;
11627 break;
11628
11629 case ssiPOTION:
11630 temp_sub->d1 = itype_potion;
11631 break;
11632
11633 case ssiLETTERPOTION:
11634 temp_sub->d1 = itype_letterpotion;
11635 break;
11636
11637 case ssiBOW:
11638 temp_sub->d1 = itype_bow;
11639 break;
11640
11641 case ssiARROW:
11642 temp_sub->d1 = itype_arrow;
11643 break;
11644
11645 case ssiBOWANDARROW:
11646 temp_sub->d1 = itype_bowandarrow;
11647 break;
11648
11649 case ssiBAIT:
11650 temp_sub->d1 = itype_bait;
11651 break;
11652
11653 case ssiRING:
11654 temp_sub->d1 = itype_ring;
11655 break;
11656
11657 case ssiBRACELET:
11658 temp_sub->d1 = itype_bracelet;
11659 break;
11660
11661 case ssiMAP:
11662 temp_sub->d1 = itype_map;
11663 break;
11664
11665 case ssiCOMPASS:
11666 temp_sub->d1 = itype_compass;
11667 break;
11668
11669 case ssiBOSSKEY:
11670 temp_sub->d1 = itype_bosskey;
11671 break;
11672
11673 case ssiMAGICKEY:
11674 temp_sub->d1 = itype_magickey;
11675 break;
11676
11677 case ssiBRANG:
11678 temp_sub->d1 = itype_brang;
11679 break;
11680
11681 case ssiWAND:
11682 temp_sub->d1 = itype_wand;
11683 break;
11684
11685 case ssiRAFT:
11686 temp_sub->d1 = itype_raft;
11687 break;
11688
11689 case ssiLADDER:
11690 temp_sub->d1 = itype_ladder;
11691 break;
11692
11693 case ssiWHISTLE:
11694 temp_sub->d1 = itype_whistle;
11695 break;
11696
11697 case ssiBOOK:
11698 temp_sub->d1 = itype_book;
11699 break;
11700
11701 case ssiWALLET:
11702 temp_sub->d1 = itype_wallet;
11703 break;
11704
11705 case ssiSBOMB:
11706 temp_sub->d1 = itype_sbomb;
11707 break;
11708
11709 case ssiHCPIECE:
11710 temp_sub->d1 = itype_heartpiece;
11711 break;
11712
11713 case ssiAMULET:
11714 temp_sub->d1 = itype_amulet;
11715 break;
11716
11717 case ssiFLIPPERS:
11718 temp_sub->d1 = itype_flippers;
11719 break;
11720
11721 case ssiHOOKSHOT:
11722 temp_sub->d1 = itype_hookshot;
11723 break;
11724
11725 case ssiLENS:
11726 temp_sub->d1 = itype_lens;
11727 break;
11728
11729 case ssiHAMMER:
11730 temp_sub->d1 = itype_hammer;
11731 break;
11732
11733 case ssiBOOTS:
11734 temp_sub->d1 = itype_boots;
11735 break;
11736
11737 case ssiDINSFIRE:
11738 temp_sub->d1 = itype_dinsfire;
11739 break;
11740
11741 case ssiFARORESWIND:
11742 temp_sub->d1 = itype_faroreswind;
11743 break;
11744
11745 case ssiNAYRUSLOVE:
11746 temp_sub->d1 = itype_nayruslove;
11747 break;
11748
11749 case ssiQUIVER:
11750 temp_sub->d1 = itype_quiver;
11751 break;
11752
11753 case ssiBOMBBAG:
11754 temp_sub->d1 = itype_bombbag;
11755 break;
11756
11757 case ssiCBYRNA:
11758 temp_sub->d1 = itype_cbyrna;
11759 break;
11760
11761 case ssiROCS:
11762 temp_sub->d1 = itype_rocs;
11763 break;
11764
11765 case ssiHOVERBOOTS:
11766 temp_sub->d1 = itype_hoverboots;
11767 break;
11768
11769 case ssiSPINSCROLL:
11770 temp_sub->d1 = itype_spinscroll;
11771 break;
11772
11773 case ssiCROSSSCROLL:
11774 temp_sub->d1 = itype_crossscroll;
11775 break;
11776
11777 case ssiQUAKESCROLL:
11778 temp_sub->d1 = itype_quakescroll;
11779 break;
11780
11781 case ssiWHISPRING:
11782 temp_sub->d1 = itype_whispring;
11783 break;
11784
11785 case ssiCHARGERING:
11786 temp_sub->d1 = itype_chargering;
11787 break;
11788
11789 case ssiPERILSCROLL:
11790 temp_sub->d1 = itype_perilscroll;
11791 break;
11792
11793 case ssiWEALTHMEDAL:
11794 temp_sub->d1 = itype_wealthmedal;
11795 break;
11796
11797 case ssiHEARTRING:
11798 temp_sub->d1 = itype_heartring;
11799 break;
11800
11801 case ssiMAGICRING:
11802 temp_sub->d1 = itype_magicring;
11803 break;
11804
11805 case ssiSPINSCROLL2:
11806 temp_sub->d1 = itype_spinscroll2;
11807 break;
11808
11809 case ssiQUAKESCROLL2:
11810 temp_sub->d1 = itype_quakescroll2;
11811 break;
11812
11813 case ssiAGONY:
11814 temp_sub->d1 = itype_agony;
11815 break;
11816
11817 case ssiSTOMPBOOTS:
11818 temp_sub->d1 = itype_stompboots;
11819 break;
11820
11821 case ssiWHIMSICALRING:
11822 temp_sub->d1 = itype_whimsicalring;
11823 break;
11824
11825 case ssiPERILRING:
11826 temp_sub->d1 = itype_perilring;
11827 break;
11828
11829 default:
11830 temp_sub->d1 += itype_custom1 - ssiMAX;
11831 }
11832 }
11833
11834 //fall-through
11835 default:
11836
1/2
✓ Branch 0 taken 1838 times.
✗ Branch 1 not taken.
1838 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11837 {
11838 return qe_invalid;
11839 }
11840
11841 1838 break;
11842 }
11843
11844
2/2
✓ Branch 0 taken 1086 times.
✓ Branch 1 taken 983 times.
2069 if(s_version < 7)
11845 {
11846
1/3
✓ Branch 0 taken 983 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
983 switch(temp_sub->type)
11847 {
11848 case ssoMAGICGAUGE:
11849 {
11850 if(!temp_sub->d9)
11851 temp_sub->d9 = -1; //-1 now represents 'always'
11852 break;
11853 }
11854 case ssoLIFEGAUGE:
11855 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11856 break;
11857 }
11858 983 }
11859
11860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2069 times.
2069 if(keepdata)
11861 {
11862
3/3
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 1792 times.
✓ Branch 2 taken 68 times.
2069 switch(temp_sub->type)
11863 {
11864 case ssoTEXT:
11865 case ssoTEXTBOX:
11866 case ssoCURRENTITEMTEXT:
11867 case ssoCURRENTITEMCLASSTEXT:
11868
1/4
✓ Branch 0 taken 209 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
209 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
11869
11870 209 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11871 209 custom_subscreen[i].objects[j].dp1 = NULL;
11872 209 custom_subscreen[i].objects[j].dp1 = new char[temp_size+1];
11873 209 strcpy((char*)custom_subscreen[i].objects[j].dp1,(char*)temp_sub->dp1);
11874 209 break;
11875
11876 case ssoCOUNTER:
11877
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 if(s_version<3)
11878 {
11879 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11880 temp_sub->d8=0;
11881 }
11882
11883 default:
11884 1860 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11885 1860 break;
11886 }
11887
11888 2069 strcpy(custom_subscreen[i].name, tempname);
11889 2069 custom_subscreen[i].ss_type = temp_ss;
11890 2069 }
11891 2069 }
11892
11893
2/2
✓ Branch 0 taken 423915 times.
✓ Branch 1 taken 1664 times.
425579 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11894 {
11895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423915 times.
423915 if(keepdata)
11896 {
11897 //clear all unused object in this subscreen -DD
11898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423915 times.
423915 switch(custom_subscreen[i].objects[j].type)
11899 {
11900 case ssoTEXT:
11901 case ssoTEXTBOX:
11902 case ssoCURRENTITEMTEXT:
11903 case ssoCURRENTITEMCLASSTEXT:
11904 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11905
11906 //fall through
11907 default:
11908 423915 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11909 423915 break;
11910 }
11911 423915 }
11912 423915 }
11913
11914 1664 return 0;
11915 1664 }
11916
11917 1024 void reset_subscreen(subscreen_group *tempss)
11918 {
11919
2/2
✓ Branch 0 taken 262144 times.
✓ Branch 1 taken 1024 times.
263168 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11920 {
11921
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 262114 times.
262144 switch(tempss->objects[i].type)
11922 {
11923 case ssoTEXT:
11924 case ssoTEXTBOX:
11925 case ssoCURRENTITEMTEXT:
11926 case ssoCURRENTITEMCLASSTEXT:
11927
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11928
11929 //fall through
11930 default:
11931 262144 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11932 262144 break;
11933 }
11934 262144 }
11935 1024 }
11936
11937 8 void reset_subscreens()
11938 {
11939
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 8 times.
1032 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
11940 {
11941 1024 reset_subscreen(&custom_subscreen[i]);
11942 1024 }
11943 8 }
11944
11945 8 int32_t setupsubscreens()
11946 {
11947 8 reset_subscreens();
11948 8 int32_t tempsubscreen=zinit.subscreen;
11949 subscreen_object *tempsub;
11950
11951
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(tempsubscreen>=ssdtMAX)
11952 {
11953 tempsubscreen=0;
11954 }
11955
11956
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
8 switch(tempsubscreen)
11957 {
11958 case ssdtOLD:
11959 case ssdtNEWSUBSCR:
11960 case ssdtREV2:
11961 case ssdtBSZELDA:
11962 case ssdtBSZELDAMODIFIED:
11963 case ssdtBSZELDAENHANCED:
11964 case ssdtBSZELDACOMPLETE:
11965 {
11966 8 tempsub = default_subscreen_active[tempsubscreen][0];
11967 int32_t i;
11968
11969
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
✓ Branch 2 taken 520 times.
✓ Branch 3 taken 8 times.
528 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
11970 {
11971
2/3
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 490 times.
✗ Branch 2 not taken.
520 switch(tempsub[i].type)
11972 {
11973 case ssoTEXT:
11974 case ssoTEXTBOX:
11975 case ssoCURRENTITEMTEXT:
11976 case ssoCURRENTITEMCLASSTEXT:
11977
1/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
11978
11979 30 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11980 30 custom_subscreen[0].objects[i].dp1 = NULL;
11981 30 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
11982 30 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
11983 30 break;
11984
11985 case ssoLIFEMETER:
11986 {
11987 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11988
11989 if(get_bit(deprecated_rules, 12) != 0)
11990 custom_subscreen[0].objects[i].d3=1;
11991 else
11992 custom_subscreen[0].objects[i].d3=0;
11993
11994 break;
11995 }
11996 /*
11997 case ssoTRIFRAME:
11998 {
11999 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12000 custom_subscreen[0].objects[i].d1 = 8594;
12001 custom_subscreen[0].objects[i].d2 = 8;
12002 custom_subscreen[0].objects[i].d3 = 8771;
12003 custom_subscreen[0].objects[i].d4 = 8;
12004 custom_subscreen[0].objects[i].d5 = 1;
12005 custom_subscreen[0].objects[i].d6 = 1;
12006 break;
12007 }*/
12008
12009 default:
12010 490 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12011 490 break;
12012 }
12013 520 }
12014
12015 8 custom_subscreen[0].ss_type=sstACTIVE;
12016 8 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
12017 8 tempsub = default_subscreen_active[tempsubscreen][1];
12018
12019
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
✓ Branch 2 taken 520 times.
✓ Branch 3 taken 8 times.
528 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12020 {
12021
2/3
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 482 times.
✗ Branch 2 not taken.
520 switch(tempsub[i].type)
12022 {
12023 case ssoTEXT:
12024 case ssoTEXTBOX:
12025 case ssoCURRENTITEMTEXT:
12026 case ssoCURRENTITEMCLASSTEXT:
12027
1/4
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12028
12029 38 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12030 38 custom_subscreen[1].objects[i].dp1 = NULL;
12031 38 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12032 38 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12033 38 break;
12034
12035 case ssoLIFEMETER:
12036 {
12037 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12038
12039 if(get_bit(deprecated_rules, 12) != 0)
12040 custom_subscreen[1].objects[i].d3=1;
12041 else
12042 custom_subscreen[1].objects[i].d3=0;
12043
12044 break;
12045 }
12046 /*
12047 case ssoTRIFRAME:
12048 {
12049 custom_subscreen[1].objects[i].d1 = 8594;
12050 custom_subscreen[1].objects[i].d2 = 8;
12051 custom_subscreen[1].objects[i].d3 = 8771;
12052 custom_subscreen[1].objects[i].d4 = 8;
12053 custom_subscreen[1].objects[i].d5 = 1;
12054 custom_subscreen[1].objects[i].d6 = 1;
12055 break;
12056 }*/
12057
12058 default:
12059 482 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12060 482 break;
12061 }
12062 520 }
12063
12064 8 custom_subscreen[1].ss_type=sstACTIVE;
12065 8 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12066 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12067 8 tempsub = default_subscreen_passive[tempsubscreen][0];
12068
12069
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 160 times.
✓ Branch 3 taken 8 times.
168 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12070 {
12071
3/3
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 8 times.
160 switch(tempsub[i].type)
12072 {
12073 case ssoTEXT:
12074 case ssoTEXTBOX:
12075 case ssoCURRENTITEMTEXT:
12076 case ssoCURRENTITEMCLASSTEXT:
12077
1/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12078
12079 24 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12080 24 custom_subscreen[2].objects[i].dp1 = NULL;
12081 24 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12082 24 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12083 24 break;
12084
12085 case ssoLIFEMETER:
12086 {
12087 8 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12088
12089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(get_bit(deprecated_rules, 12) != 0)
12090 custom_subscreen[2].objects[i].d3=1;
12091 else
12092 8 custom_subscreen[2].objects[i].d3=0;
12093
12094 8 break;
12095 }
12096
12097 default:
12098 128 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12099 128 break;
12100 }
12101 160 }
12102
12103 8 custom_subscreen[2].ss_type=sstPASSIVE;
12104 8 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12105 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12106 8 tempsub = default_subscreen_passive[tempsubscreen][1];
12107
12108
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 152 times.
✓ Branch 3 taken 8 times.
160 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12109 {
12110
3/3
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 8 times.
152 switch(tempsub[i].type)
12111 {
12112 case ssoTEXT:
12113 case ssoTEXTBOX:
12114 case ssoCURRENTITEMTEXT:
12115 case ssoCURRENTITEMCLASSTEXT:
12116
1/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12117
12118 24 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12119 24 custom_subscreen[3].objects[i].dp1 = NULL;
12120 24 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12121 24 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12122 24 break;
12123
12124 case ssoLIFEMETER:
12125 {
12126 8 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12127
12128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(get_bit(deprecated_rules, 12) != 0)
12129 custom_subscreen[3].objects[i].d3=1;
12130 else
12131 8 custom_subscreen[3].objects[i].d3=0;
12132
12133 8 break;
12134 }
12135
12136 default:
12137 120 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12138 120 break;
12139 }
12140 152 }
12141
12142 8 custom_subscreen[3].ss_type=sstPASSIVE;
12143 8 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12144 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12145 8 break;
12146 }
12147
12148 case ssdtZ3:
12149 {
12150 tempsub = z3_active_a;
12151 int32_t i;
12152
12153 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12154 {
12155 switch(tempsub[i].type)
12156 {
12157 case ssoTEXT:
12158 case ssoTEXTBOX:
12159 case ssoCURRENTITEMTEXT:
12160 case ssoCURRENTITEMCLASSTEXT:
12161 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12162
12163 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12164 custom_subscreen[0].objects[i].dp1 = NULL;
12165 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12166 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12167 break;
12168
12169 case ssoLIFEMETER:
12170 {
12171 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12172
12173 if(get_bit(deprecated_rules, 12) != 0)
12174 custom_subscreen[0].objects[i].d3=1;
12175 else
12176 custom_subscreen[0].objects[i].d3=0;
12177
12178 break;
12179 }
12180
12181 default:
12182 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12183 break;
12184 }
12185 }
12186
12187 custom_subscreen[0].ss_type=sstACTIVE;
12188 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12189 tempsub = z3_active_ab;
12190
12191 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12192 {
12193 switch(tempsub[i].type)
12194 {
12195 case ssoTEXT:
12196 case ssoTEXTBOX:
12197 case ssoCURRENTITEMTEXT:
12198 case ssoCURRENTITEMCLASSTEXT:
12199 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12200
12201 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12202 custom_subscreen[1].objects[i].dp1 = NULL;
12203 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12204 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12205 break;
12206
12207 case ssoLIFEMETER:
12208 {
12209 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12210
12211 if(get_bit(deprecated_rules, 12) != 0)
12212 custom_subscreen[1].objects[i].d3=1;
12213 else
12214 custom_subscreen[1].objects[i].d3=0;
12215
12216 break;
12217 }
12218
12219 default:
12220 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12221 break;
12222 }
12223 }
12224
12225 custom_subscreen[1].ss_type=sstACTIVE;
12226 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12227 tempsub = z3_passive_a;
12228
12229 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12230 {
12231 switch(tempsub[i].type)
12232 {
12233 case ssoTEXT:
12234 case ssoTEXTBOX:
12235 case ssoCURRENTITEMTEXT:
12236 case ssoCURRENTITEMCLASSTEXT:
12237 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12238
12239 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12240 custom_subscreen[2].objects[i].dp1 = NULL;
12241 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12242 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12243 break;
12244
12245 case ssoLIFEMETER:
12246 {
12247 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12248
12249 if(get_bit(deprecated_rules, 12) != 0)
12250 custom_subscreen[2].objects[i].d3=1;
12251 else
12252 custom_subscreen[2].objects[i].d3=0;
12253
12254 break;
12255 }
12256
12257 default:
12258 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12259 break;
12260 }
12261 }
12262
12263 custom_subscreen[2].ss_type=sstPASSIVE;
12264 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12265 tempsub = z3_passive_ab;
12266
12267 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12268 {
12269 switch(tempsub[i].type)
12270 {
12271 case ssoTEXT:
12272 case ssoTEXTBOX:
12273 case ssoCURRENTITEMTEXT:
12274 case ssoCURRENTITEMCLASSTEXT:
12275 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12276
12277 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12278 custom_subscreen[3].objects[i].dp1 = NULL;
12279 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12280 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12281 break;
12282
12283 case ssoLIFEMETER:
12284 {
12285 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12286
12287 if(get_bit(deprecated_rules, 12) != 0)
12288 custom_subscreen[3].objects[i].d3=1;
12289 else
12290 custom_subscreen[3].objects[i].d3=0;
12291
12292 break;
12293 }
12294
12295 default:
12296 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12297 break;
12298 }
12299 }
12300
12301 custom_subscreen[3].ss_type=sstPASSIVE;
12302 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12303 break;
12304 }
12305 }
12306
12307
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 32 times.
40 for(int32_t i=0; i<4; ++i)
12308 {
12309 32 purge_blank_subscreen_objects(&custom_subscreen[i]);
12310 32 }
12311
12312 8 return 0;
12313 }
12314
12315 extern script_data *ffscripts[NUMSCRIPTFFC];
12316 extern script_data *itemscripts[NUMSCRIPTITEM];
12317 extern script_data *guyscripts[NUMSCRIPTGUYS];
12318 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12319 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12320 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12321 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12322 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12323 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12324 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12325 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12326 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12327 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12328 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12329
12330
12331
12332 13 int32_t readffscript(PACKFILE *f, zquestheader *Header, bool keepdata)
12333 {
12334 int32_t dummy;
12335 13 word s_version=0, s_cversion=0, zmeta_version=0;
12336 13 byte numscripts=0;
12337 13 numscripts=numscripts; //to avoid unused variables warnings
12338 int32_t ret;
12339
12340 //section version info
12341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!p_igetw(&s_version,f,true))
12342 {
12343 return qe_invalid;
12344 }
12345
12346 13 FFCore.quest_format[vFFScript] = s_version;
12347
12348
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_cversion,f,true))
12349 {
12350 return qe_invalid;
12351 }
12352
12353
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(s_version >= 18)
12354 {
12355
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetw(&zmeta_version,f,true))
12356 {
12357 return qe_invalid;
12358 }
12359 2 }
12360
12361 //al_trace("Scripts version %d\n", s_version);
12362 //section size
12363
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy,f,true))
12364 {
12365 return qe_invalid;
12366 }
12367
12368 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12369 13 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12370 13 temp_ffscript_version = s_version;
12371 //miscQdata *the_misc;
12372
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12373 13 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12374
12375 //finally... section data
12376
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 13 times.
6669 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12377 {
12378 6656 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12379
12380
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(ret != 0) return qe_invalid;
12381 6656 }
12382
12383 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12384 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12385 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12386 * there was a version bump a week before a change that broke stuff.
12387 */
12388
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 11 times.
13 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)) && keepdata)
12389 {
12390 11 set_bit(quest_rules,qr_SPRITE_JUMP_IS_TRUNCATED,1);
12391 11 }
12392
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
13 if(s_version < 19 && keepdata)
12393 {
12394 11 set_bit(quest_rules,qr_FLUCTUATING_ENEMY_JUMP,1);
12395 11 }
12396
12397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version > 1)
12398 {
12399
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12400 {
12401 3328 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12402
12403
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(ret != 0) return qe_invalid;
12404 3328 }
12405
12406
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12407 {
12408 3328 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12409
12410
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(ret != 0) return qe_invalid;
12411 3328 }
12412
12413
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12414 {
12415 3328 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12416
12417
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(ret != 0) return qe_invalid;
12418 3328 }
12419
12420
12421
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12422 {
12423 3328 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12424
12425
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 if(ret != 0) return qe_invalid;
12426 3328 }
12427
12428
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version > 16)
12429 {
12430
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
18 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12431 {
12432 16 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12433
12434
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(ret != 0) return qe_invalid;
12435 16 }
12436 2 }
12437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 else if(s_version > 13)
12438 {
12439 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12440 {
12441 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12442
12443 if(ret != 0) return qe_invalid;
12444 }
12445
12446 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12447 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12448
12449 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12450 }
12451
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 else if(s_version > 4)
12452 {
12453
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12454 {
12455 44 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12456
12457
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if(ret != 0) return qe_invalid;
12458 44 }
12459
12460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12461
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12462
12463
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12464
12465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12466
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12467
12468
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12469
12470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12471
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 delete globalscripts[GLOBAL_SCRIPT_F6];
12472
12473
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12474
12475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12476
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12477
12478
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12479 11 }
12480 else
12481 {
12482 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12483 {
12484 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12485
12486 if(ret != 0) return qe_invalid;
12487 }
12488
12489 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12490 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12491
12492 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12493
12494 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12495 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12496
12497 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12498
12499 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12500 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12501
12502 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12503
12504 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12505 delete globalscripts[GLOBAL_SCRIPT_F6];
12506
12507 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12508
12509 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12510 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12511
12512 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12513 }
12514
12515
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version > 10) //expanded the number of Player scripts to 5.
12516 {
12517
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 2 times.
12 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12518 {
12519 10 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12520
12521
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(ret != 0) return qe_invalid;
12522 10 }
12523 2 }
12524 else
12525 {
12526
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 11 times.
44 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12527 {
12528 33 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12529
12530
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(ret != 0) return qe_invalid;
12531 33 }
12532
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(playerscripts[3] != NULL)
12533
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 delete playerscripts[3];
12534
12535
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 playerscripts[3] = new script_data();
12536
12537
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(playerscripts[4] != NULL)
12538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 delete playerscripts[4];
12539
12540
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 playerscripts[4] = new script_data();
12541 }
12542
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
13 if(s_version > 8 && s_version < 10)
12543 {
12544
12545 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12546 {
12547 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12548
12549 if(ret != 0) return qe_invalid;
12550 }
12551 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12552 {
12553 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12554
12555 if(ret != 0) return qe_invalid;
12556 }
12557
12558 }
12559
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(s_version >= 10)
12560 {
12561
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2 times.
514 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12562 {
12563 512 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12564
12565
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(ret != 0) return qe_invalid;
12566 512 }
12567
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2 times.
514 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12568 {
12569 512 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12570
12571
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(ret != 0) return qe_invalid;
12572 512 }
12573
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2 times.
514 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12574 {
12575 512 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12576
12577
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(ret != 0) return qe_invalid;
12578 512 }
12579
12580 2 }
12581
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(s_version >=12)
12582 {
12583
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2 times.
514 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12584 {
12585 512 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12586
12587
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(ret != 0) return qe_invalid;
12588 512 }
12589 2 }
12590
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(s_version >=15)
12591 {
12592
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 2 times.
1026 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12593 {
12594 1024 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12595
12596
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(ret != 0) return qe_invalid;
12597 1024 }
12598 2 }
12599
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(s_version >19)
12600 {
12601 2 word numgenscripts = NUMSCRIPTSGENERIC;
12602
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetw(&numgenscripts,f,true))
12603 {
12604 return qe_invalid;
12605 }
12606
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 2 times.
1026 for(int32_t i = 0; i < numgenscripts; i++)
12607 {
12608 1024 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12609
12610
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(ret != 0) return qe_invalid;
12611 1024 }
12612 2 }
12613
12614 /*
12615 else //Is this trip really necessary?
12616 {
12617 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12618 {
12619
12620 ewpnscripts[i] = NULL;
12621 }
12622 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12623 {
12624 dmapscripts[i] = NULL;
12625 }
12626 }
12627 */
12628
12629 13 }
12630
12631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version > 2)
12632 {
12633 int32_t bufsize;
12634 13 p_igetl(&bufsize, f, true);
12635 13 char * buf = new char[bufsize+1];
12636 13 pfread(buf, bufsize, f, true);
12637 13 buf[bufsize]=0;
12638
12639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata)
12640 13 zScript = string(buf);
12641
12642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 delete[] buf;
12643 word numffcbindings;
12644 13 p_igetw(&numffcbindings, f, true);
12645
12646
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 13 times.
66 for(int32_t i=0; i<numffcbindings; i++)
12647 {
12648 word id;
12649 53 p_igetw(&id, f, true);
12650 53 p_igetl(&bufsize, f, true);
12651 53 buf = new char[bufsize+1];
12652 53 pfread(buf, bufsize, f, true);
12653 53 buf[bufsize]=0;
12654
12655 //fix for buggy older saved quests -DD
12656
2/4
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 53 times.
53 if(keepdata && id < NUMSCRIPTFFC-1)
12657 53 ffcmap[id].scriptname = buf;
12658
12659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 delete[] buf;
12660 53 }
12661
12662 word numglobalbindings;
12663 13 p_igetw(&numglobalbindings, f, true);
12664
12665
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 13 times.
50 for(int32_t i=0; i<numglobalbindings; i++)
12666 {
12667 word id;
12668 37 p_igetw(&id, f, true);
12669 37 p_igetl(&bufsize, f, true);
12670 37 buf = new char[bufsize+1];
12671 37 pfread(buf, bufsize, f, true);
12672 37 buf[bufsize]=0;
12673
12674 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12675 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12676 // Ignore these. -DD
12677
4/6
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 28 times.
37 if(keepdata && id >= 0 && id < NUMSCRIPTGLOBAL)
12678 {
12679 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12680
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(strcmp(buf,"~Continue") == 0)
12681 {
12682 globalmap[id].scriptname = "";
12683
12684 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12685 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12686 }
12687 else
12688 {
12689 28 globalmap[id].scriptname = buf;
12690 }
12691 28 }
12692
12693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 delete[] buf;
12694 37 }
12695
12696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version > 3)
12697 {
12698 word numitembindings;
12699 13 p_igetw(&numitembindings, f, true);
12700
12701
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 for(int32_t i=0; i<numitembindings; i++)
12702 {
12703 word id;
12704 1 p_igetw(&id, f, true);
12705 1 p_igetl(&bufsize, f, true);
12706 1 buf = new char[bufsize+1];
12707 1 pfread(buf, bufsize, f, true);
12708 1 buf[bufsize]=0;
12709
12710 //fix this too
12711
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(keepdata && id <NUMSCRIPTITEM-1)
12712 1 itemmap[id].scriptname = buf;
12713
12714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 delete[] buf;
12715 1 }
12716 13 }
12717 //(v9+)
12718
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(s_version > 8)
12719 {
12720 //npc scripts
12721 word numnpcbindings;
12722 2 p_igetw(&numnpcbindings, f, true);
12723
12724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<numnpcbindings; i++)
12725 {
12726 word id;
12727 p_igetw(&id, f, true);
12728 p_igetl(&bufsize, f, true);
12729 buf = new char[bufsize+1];
12730 pfread(buf, bufsize, f, true);
12731 buf[bufsize]=0;
12732
12733 //fix this too
12734 if(keepdata && id <NUMSCRIPTGUYS-1)
12735 npcmap[id].scriptname = buf;
12736
12737 delete[] buf;
12738 }
12739 //lweapon
12740 word numlwpnbindings;
12741 2 p_igetw(&numlwpnbindings, f, true);
12742
12743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<numlwpnbindings; i++)
12744 {
12745 word id;
12746 p_igetw(&id, f, true);
12747 p_igetl(&bufsize, f, true);
12748 buf = new char[bufsize+1];
12749 pfread(buf, bufsize, f, true);
12750 buf[bufsize]=0;
12751
12752 //fix this too
12753 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12754 lwpnmap[id].scriptname = buf;
12755
12756 delete[] buf;
12757 }
12758 //eweapon
12759 word numewpnbindings;
12760 2 p_igetw(&numewpnbindings, f, true);
12761
12762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<numewpnbindings; i++)
12763 {
12764 word id;
12765 p_igetw(&id, f, true);
12766 p_igetl(&bufsize, f, true);
12767 buf = new char[bufsize+1];
12768 pfread(buf, bufsize, f, true);
12769 buf[bufsize]=0;
12770
12771 //fix this too
12772 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12773 ewpnmap[id].scriptname = buf;
12774
12775 delete[] buf;
12776 }
12777 //hero
12778 word numherobindings;
12779 2 p_igetw(&numherobindings, f, true);
12780
12781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<numherobindings; i++)
12782 {
12783 word id;
12784 p_igetw(&id, f, true);
12785 p_igetl(&bufsize, f, true);
12786 buf = new char[bufsize+1];
12787 pfread(buf, bufsize, f, true);
12788 buf[bufsize]=0;
12789
12790 //fix this too
12791 if(keepdata && id <NUMSCRIPTPLAYER-1)
12792 playermap[id].scriptname = buf;
12793
12794 delete[] buf;
12795 }
12796 //dmaps
12797 word numdmapbindings;
12798 2 p_igetw(&numdmapbindings, f, true);
12799
12800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<numdmapbindings; i++)
12801 {
12802 word id;
12803 p_igetw(&id, f, true);
12804 p_igetl(&bufsize, f, true);
12805 buf = new char[bufsize+1];
12806 pfread(buf, bufsize, f, true);
12807 buf[bufsize]=0;
12808
12809 //fix this too
12810 if(keepdata && id <NUMSCRIPTSDMAP-1)
12811 dmapmap[id].scriptname = buf;
12812
12813 delete[] buf;
12814 }
12815 //screen
12816 word numscreenbindings;
12817 2 p_igetw(&numscreenbindings, f, true);
12818
12819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<numscreenbindings; i++)
12820 {
12821 word id;
12822 p_igetw(&id, f, true);
12823 p_igetl(&bufsize, f, true);
12824 buf = new char[bufsize+1];
12825 pfread(buf, bufsize, f, true);
12826 buf[bufsize]=0;
12827
12828 //fix this too
12829 if(keepdata && id <NUMSCRIPTSDMAP-1)
12830 screenmap[id].scriptname = buf;
12831
12832 delete[] buf;
12833 }
12834 2 }
12835
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(s_version > 11)
12836 {
12837 word numspritebindings;
12838 2 p_igetw(&numspritebindings, f, true);
12839
12840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<numspritebindings; i++)
12841 {
12842 word id;
12843 p_igetw(&id, f, true);
12844 p_igetl(&bufsize, f, true);
12845 buf = new char[bufsize+1];
12846 pfread(buf, bufsize, f, true);
12847 buf[bufsize]=0;
12848
12849 //fix this too
12850 if(keepdata && id <NUMSCRIPTSDMAP-1)
12851 itemspritemap[id].scriptname = buf;
12852
12853 delete[] buf;
12854 }
12855 2 }
12856
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(s_version >= 15)
12857 {
12858 word numcombobindings;
12859 2 p_igetw(&numcombobindings, f, true);
12860
12861
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 for(int32_t i=0; i<numcombobindings; i++)
12862 {
12863 word id;
12864 1 p_igetw(&id, f, true);
12865 1 p_igetl(&bufsize, f, true);
12866 1 buf = new char[bufsize+1];
12867 1 pfread(buf, bufsize, f, true);
12868 1 buf[bufsize]=0;
12869
12870 //fix this too
12871
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(keepdata && id <NUMSCRIPTSCOMBODATA-1)
12872 1 comboscriptmap[id].scriptname = buf;
12873
12874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 delete[] buf;
12875 1 }
12876 2 }
12877
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(s_version > 19)
12878 {
12879 word numgenericbindings;
12880 2 p_igetw(&numgenericbindings, f, true);
12881
12882
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 for(int32_t i=0; i<numgenericbindings; i++)
12883 {
12884 word id;
12885 1 p_igetw(&id, f, true);
12886 1 p_igetl(&bufsize, f, true);
12887 1 buf = new char[bufsize+1];
12888 1 pfread(buf, bufsize, f, true);
12889 1 buf[bufsize]=0;
12890
12891 //fix this too
12892
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(keepdata && id <NUMSCRIPTSGENERIC-1)
12893 1 genericmap[id].scriptname = buf;
12894
12895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 delete[] buf;
12896 1 }
12897 2 }
12898 13 }
12899
12900 13 return 0;
12901 13 }
12902
12903 13 void reset_scripts()
12904 {
12905 //OK, who spaced this? ;)
12906
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 13 times.
6669 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12907 {
12908
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6656 times.
6656 if(ffscripts[i]!=NULL) delete ffscripts[i];
12909 6656 }
12910
12911
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12912 {
12913
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3328 times.
3328 if(itemscripts[i]!=NULL) delete itemscripts[i];
12914 3328 }
12915
12916
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12917 {
12918
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3328 times.
3328 if(guyscripts[i]!=NULL) delete guyscripts[i];
12919 3328 }
12920
12921
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12922 {
12923
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3328 times.
3328 if(wpnscripts[i]!=NULL) delete wpnscripts[i];
12924 3328 }
12925
12926
12927
12928
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12929 {
12930
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3328 times.
3328 if(screenscripts[i]!=NULL) delete screenscripts[i];
12931 3328 }
12932
12933
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 13 times.
117 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12934 {
12935
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(globalscripts[i]!=NULL) delete globalscripts[i];
12936 104 }
12937
12938
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 13 times.
78 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12939 {
12940
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 65 times.
65 if(playerscripts[i]!=NULL) delete playerscripts[i];
12941 65 }
12942
12943
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12944 {
12945
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3328 times.
3328 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
12946 3328 }
12947
12948
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12949 {
12950
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3328 times.
3328 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
12951 3328 }
12952
12953
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12954 {
12955
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3328 times.
3328 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
12956 3328 }
12957
12958
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12959 {
12960
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3328 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3328 times.
3328 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
12961 3328 }
12962
12963
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 13 times.
6669 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12964 {
12965
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6656 times.
6656 if(comboscripts[i]!=NULL) delete comboscripts[i];
12966 6656 }
12967
12968
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 13 times.
6669 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12969 {
12970
3/4
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
✓ Branch 2 taken 1024 times.
✗ Branch 3 not taken.
6656 if(genericscripts[i]!=NULL) delete genericscripts[i];
12971
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 genericscripts[i] = new script_data();
12972 6656 }
12973
12974
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 13 times.
6669 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12975 {
12976
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 ffscripts[i] = new script_data();
12977 6656 }
12978
12979
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12980 {
12981
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 itemscripts[i] = new script_data();
12982 3328 }
12983
12984
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12985 {
12986
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 guyscripts[i] = new script_data();
12987 3328 }
12988
12989
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12990 {
12991
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 wpnscripts[i] = new script_data();
12992 3328 }
12993
12994
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12995 {
12996
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 screenscripts[i] = new script_data();
12997 3328 }
12998
12999
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 13 times.
117 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13000 {
13001
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 globalscripts[i] = new script_data();
13002 104 }
13003
13004
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 13 times.
78 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13005 {
13006
1/2
✓ Branch 0 taken 65 times.
✗ Branch 1 not taken.
65 playerscripts[i] = new script_data();
13007 65 }
13008
13009
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13010 {
13011
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 lwpnscripts[i] = new script_data();
13012 3328 }
13013
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13014 {
13015
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 ewpnscripts[i] = new script_data();
13016 3328 }
13017
13018
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13019 {
13020
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 dmapscripts[i] = new script_data();
13021 3328 }
13022
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13023 {
13024
1/2
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
3328 itemspritescripts[i] = new script_data();
13025 3328 }
13026
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 13 times.
6669 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13027 {
13028
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 comboscripts[i] = new script_data();
13029 6656 }
13030 13 }
13031
13032 extern script_command command_list[];
13033 24167 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, bool keepdata, int32_t , word s_version, word , script_data **script, word zmeta_version)
13034 {
13035 //Please also update loadquest() when modifying this method -DD
13036 24167 char b33[34] = {0};
13037 24167 b33[33] = 0;
13038 24167 ffscript temp_script;
13039 24167 int32_t num_commands=1000;
13040
13041
1/2
✓ Branch 0 taken 24167 times.
✗ Branch 1 not taken.
24167 if(s_version>=2)
13042 {
13043
2/4
✓ Branch 0 taken 24167 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24167 times.
✗ Branch 3 not taken.
24167 if(!p_igetl(&num_commands,f,true))
13044 {
13045 return qe_invalid;
13046 }
13047 24167 }
13048
13049
1/2
✓ Branch 0 taken 24167 times.
✗ Branch 1 not taken.
24167 if(keepdata)
13050 {
13051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24167 times.
24167 if((*script) != NULL) //Surely we want to do this regardless of keepdata? //No, we don't -V
13052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24167 times.
24167 delete (*script);
13053
2/4
✓ Branch 0 taken 24167 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24167 times.
✗ Branch 3 not taken.
24167 (*script) = new script_data(num_commands);
13054 24167 }
13055
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 16973 times.
24167 if(s_version >= 16)
13056 {
13057
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 zasm_meta temp_meta;
13058
13059
2/4
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7194 times.
✗ Branch 3 not taken.
7194 if(!p_igetw(&(temp_meta.zasm_v),f,true))
13060 {
13061 return qe_invalid;
13062 }
13063
13064
2/4
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7194 times.
✗ Branch 3 not taken.
7194 if(!p_igetw(&(temp_meta.meta_v),f,true))
13065 {
13066 return qe_invalid;
13067 }
13068
13069
2/4
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7194 times.
✗ Branch 3 not taken.
7194 if(!p_igetw(&(temp_meta.ffscript_v),f,true))
13070 {
13071 return qe_invalid;
13072 }
13073
13074
2/4
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7194 times.
✗ Branch 3 not taken.
7194 if(!p_getc(&(temp_meta.script_type),f,true))
13075 {
13076 return qe_invalid;
13077 }
13078
13079
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(int32_t q = 0; q < 8; ++q)
13080 {
13081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57552 times.
57552 if(zmeta_version < 3)
13082 {
13083 for(int32_t c = 0; c < 33; ++c)
13084 {
13085 if(!p_getc(&(b33[c]),f,true))
13086 {
13087 return qe_invalid;
13088 }
13089 }
13090 temp_meta.run_idens[q].assign(b33);
13091 }
13092 else
13093 {
13094
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getcstr(&temp_meta.run_idens[q],f,true))
13095 {
13096 return qe_invalid;
13097 }
13098 }
13099 57552 }
13100
13101
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 57552 times.
64746 for(int32_t q = 0; q < 8; ++q)
13102 {
13103
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getc(&(temp_meta.run_types[q]),f,true))
13104 {
13105 return qe_invalid;
13106 }
13107 57552 }
13108
13109
2/4
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7194 times.
✗ Branch 3 not taken.
7194 if(!p_getc(&(temp_meta.flags),f,true))
13110 {
13111 return qe_invalid;
13112 }
13113
13114
2/4
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7194 times.
✗ Branch 3 not taken.
7194 if(!p_igetw(&(temp_meta.compiler_v1),f,true))
13115 {
13116 return qe_invalid;
13117 }
13118
13119
2/4
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7194 times.
✗ Branch 3 not taken.
7194 if(!p_igetw(&(temp_meta.compiler_v2),f,true))
13120 {
13121 return qe_invalid;
13122 }
13123
13124
2/4
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7194 times.
✗ Branch 3 not taken.
7194 if(!p_igetw(&(temp_meta.compiler_v3),f,true))
13125 {
13126 return qe_invalid;
13127 }
13128
13129
2/4
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7194 times.
✗ Branch 3 not taken.
7194 if(!p_igetw(&(temp_meta.compiler_v4),f,true))
13130 {
13131 return qe_invalid;
13132 }
13133
13134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7194 times.
7194 if(zmeta_version == 2)
13135 {
13136 for(int32_t c = 0; c < 33; ++c)
13137 {
13138 if(!p_getc(&b33[c],f,true))
13139 {
13140 return qe_invalid;
13141 }
13142 }
13143 temp_meta.script_name.assign(b33);
13144
13145 for(int32_t c = 0; c < 33; ++c)
13146 {
13147 if(!p_getc(&b33[c],f,true))
13148 {
13149 return qe_invalid;
13150 }
13151 }
13152 temp_meta.author.assign(b33);
13153 }
13154
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 else if(zmeta_version > 2)
13155 {
13156
2/4
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7194 times.
✗ Branch 3 not taken.
7194 if(!p_getcstr(&temp_meta.script_name,f,true))
13157 return qe_invalid;
13158
2/4
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7194 times.
✗ Branch 3 not taken.
7194 if(!p_getcstr(&temp_meta.author,f,true))
13159 return qe_invalid;
13160 7194 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13161
2/2
✓ Branch 0 taken 71940 times.
✓ Branch 1 taken 7194 times.
79134 for(auto q = 0; q < num_meta_attrib; ++q)
13162 {
13163
2/4
✓ Branch 0 taken 71940 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71940 times.
✗ Branch 3 not taken.
71940 if(!p_getcstr(&temp_meta.attributes[q],f,true))
13164 return qe_invalid;
13165
2/4
✓ Branch 0 taken 71940 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71940 times.
✗ Branch 3 not taken.
71940 if(!p_getwstr(&temp_meta.attributes_help[q],f,true))
13166 return qe_invalid;
13167 71940 }
13168
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13169 {
13170
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getcstr(&temp_meta.attribytes[q],f,true))
13171 return qe_invalid;
13172
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getwstr(&temp_meta.attribytes_help[q],f,true))
13173 return qe_invalid;
13174 57552 }
13175
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13176 {
13177
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getcstr(&temp_meta.attrishorts[q],f,true))
13178 return qe_invalid;
13179
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getwstr(&temp_meta.attrishorts_help[q],f,true))
13180 return qe_invalid;
13181 57552 }
13182
2/2
✓ Branch 0 taken 115104 times.
✓ Branch 1 taken 7194 times.
122298 for(auto q = 0; q < 16; ++q)
13183 {
13184
2/4
✓ Branch 0 taken 115104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115104 times.
✗ Branch 3 not taken.
115104 if(!p_getcstr(&temp_meta.usrflags[q],f,true))
13185 return qe_invalid;
13186
2/4
✓ Branch 0 taken 115104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115104 times.
✗ Branch 3 not taken.
115104 if(!p_getwstr(&temp_meta.usrflags_help[q],f,true))
13187 return qe_invalid;
13188 115104 }
13189 7194 }
13190
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 if(zmeta_version > 3)
13191 {
13192
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13193 {
13194
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getcstr(&temp_meta.initd[q],f,true))
13195 return qe_invalid;
13196
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getwstr(&temp_meta.initd_help[q],f,true))
13197 return qe_invalid;
13198 57552 }
13199
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13200 {
13201
2/4
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57552 times.
✗ Branch 3 not taken.
57552 if(!p_getc(&temp_meta.initd_type[q],f,true))
13202 return qe_invalid;
13203 57552 }
13204 7194 }
13205 else
13206 {
13207 for(auto q = 0; q < 8; ++q)
13208 {
13209 temp_meta.initd[q] = temp_meta.run_idens[q];
13210 }
13211 }
13212
13213
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 if(keepdata)
13214
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 (*script)->meta = temp_meta;
13215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7194 times.
7194 }
13216
13217
1/2
✓ Branch 0 taken 24167 times.
✗ Branch 1 not taken.
24167 temp_script.clear();
13218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247491 times.
247491 for(int32_t j=0; j<num_commands; j++)
13219 {
13220
2/4
✓ Branch 0 taken 247491 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 247491 times.
✗ Branch 3 not taken.
247491 if(!p_igetw(&(temp_script.command),f,true))
13221 {
13222 return qe_invalid;
13223 }
13224
13225
2/2
✓ Branch 0 taken 223324 times.
✓ Branch 1 taken 24167 times.
247491 if(temp_script.command == 0xFFFF)
13226 {
13227
1/2
✓ Branch 0 taken 24167 times.
✗ Branch 1 not taken.
24167 if(keepdata)
13228
1/2
✓ Branch 0 taken 24167 times.
✗ Branch 1 not taken.
24167 (*script)->zasm[j].clear();
13229 24167 break;
13230 }
13231 else
13232 {
13233
2/4
✓ Branch 0 taken 223324 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 223324 times.
✗ Branch 3 not taken.
223324 if(!p_igetl(&(temp_script.arg1),f,keepdata))
13234 {
13235 return qe_invalid;
13236 }
13237
13238
2/4
✓ Branch 0 taken 223324 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 223324 times.
✗ Branch 3 not taken.
223324 if(!p_igetl(&(temp_script.arg2),f,keepdata))
13239 {
13240 return qe_invalid;
13241 }
13242
13243
2/2
✓ Branch 0 taken 1247 times.
✓ Branch 1 taken 222077 times.
223324 if(s_version >= 21)
13244 {
13245 1247 uint32_t sz = 0;
13246
2/4
✓ Branch 0 taken 1247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1247 times.
✗ Branch 3 not taken.
1247 if(!p_igetl(&sz,f,keepdata))
13247 {
13248 return qe_invalid;
13249 }
13250
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1242 times.
1247 if(sz) //string found
13251 {
13252
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 temp_script.strptr = new std::string();
13253 char dummy;
13254
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 5 times.
64 for(size_t q = 0; q < sz; ++q)
13255 {
13256
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_getc(&dummy,f,keepdata))
13257 {
13258 return qe_invalid;
13259 }
13260
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 temp_script.strptr->push_back(dummy);
13261 59 }
13262 5 }
13263
2/4
✓ Branch 0 taken 1247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1247 times.
✗ Branch 3 not taken.
1247 if(!p_igetl(&sz,f,keepdata))
13264 {
13265 return qe_invalid;
13266 }
13267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1247 times.
1247 if(sz) //vector found
13268 {
13269 temp_script.vecptr = new std::vector<int32_t>();
13270 int32_t dummy;
13271 for(size_t q = 0; q < sz; ++q)
13272 {
13273 if(!p_igetl(&dummy,f,keepdata))
13274 {
13275 return qe_invalid;
13276 }
13277 temp_script.vecptr->push_back(dummy);
13278 }
13279 }
13280 1247 }
13281
13282
1/2
✓ Branch 0 taken 223324 times.
✗ Branch 1 not taken.
223324 if(keepdata)
13283 {
13284
1/2
✓ Branch 0 taken 223324 times.
✗ Branch 1 not taken.
223324 temp_script.give((*script)->zasm[j]);
13285 223324 }
13286 }
13287
1/2
✓ Branch 0 taken 223324 times.
✗ Branch 1 not taken.
223324 temp_script.clear();
13288 223324 }
13289
13290 24167 return 0;
13291 24167 }
13292
13293 extern SAMPLE customsfxdata[WAV_COUNT];
13294 extern uint8_t customsfxflag[WAV_COUNT>>3];
13295 extern int32_t sfxdat;
13296 extern DATAFILE *sfxdata;
13297 const char *old_sfx_string[Z35] =
13298 {
13299 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13300 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13301 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13302 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13303 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13304 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13305 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13306 "Din's Fire", "Enemy falls from ceiling", "Farore's Wind", "Fireball", "Tall Grass slashed",
13307 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13308 "Nayru's Love shield", "Nayru's Love shield 2", "Push block", "Rock", "Spell rocket down",
13309 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13310 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13311 };
13312 char *sfx_string[WAV_COUNT];
13313
13314 13 int32_t readsfx(PACKFILE *f, zquestheader *Header, bool keepdata)
13315 {
13316 //these are here to bypass compiler warnings about unused arguments
13317 13 Header=Header;
13318
13319 int32_t dummy;
13320 13 word s_version=0, s_cversion=0;
13321 //int32_t ret;
13322 SAMPLE temp_sample;
13323 13 temp_sample.loop_start=0;
13324 13 temp_sample.loop_end=0;
13325 13 temp_sample.param=0;
13326
13327 //section version info
13328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!p_igetw(&s_version,f,true))
13329 {
13330 return qe_invalid;
13331 }
13332
13333 13 FFCore.quest_format[vSFX] = s_version;
13334
13335 //al_trace("SFX version %d\n", s_version);
13336
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_cversion,f,true))
13337 {
13338 return qe_invalid;
13339 }
13340
13341 //section size
13342
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy,f,true))
13343 {
13344 return qe_invalid;
13345 }
13346
13347 /* HIGHLY UNORTHODOX UPDATING THING, by L
13348 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13349 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13350 * changing from 1 to 2.
13351 */
13352
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if(s_version < 2 && keepdata)
13353 set_bit(quest_rules,qr_GOTOLESSNOTEQUAL,1);
13354
13355 /* End highly unorthodox updating thing */
13356
13357 13 int32_t wavcount = WAV_COUNT;
13358
13359
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version < 6)
13360 wavcount = 128;
13361
13362 uint8_t tempflag[WAV_COUNT>>3];
13363
13364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version < 4)
13365 {
13366 memset(tempflag, 0xFF, WAV_COUNT>>3);
13367 }
13368 else
13369 {
13370
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version < 6)
13371 memset(tempflag, 0, WAV_COUNT>>3);
13372
13373
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 13 times.
429 for(int32_t i=0; i<(wavcount>>3); i++)
13374 {
13375 416 p_getc(&tempflag[i], f, true);
13376 416 }
13377
13378 }
13379
13380
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version>4)
13381 {
13382
2/2
✓ Branch 0 taken 3315 times.
✓ Branch 1 taken 13 times.
3328 for(int32_t i=1; i<WAV_COUNT; i++)
13383 {
13384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3315 times.
3315 if(keepdata)
13385 {
13386 3315 sprintf(sfx_string[i],"s%03d",i);
13387
13388
2/2
✓ Branch 0 taken 2535 times.
✓ Branch 1 taken 780 times.
3315 if((i<Z35))
13389 780 strcpy(sfx_string[i], old_sfx_string[i-1]);
13390 3315 }
13391
13392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3315 times.
3315 if(i>=wavcount)
13393 continue;
13394
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 3173 times.
3315 if(get_bit(tempflag, i-1))
13395 {
13396 char tempname[36];
13397
13398
1/2
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
142 if(!pfread(tempname, 36, f, keepdata))
13399 {
13400 return qe_invalid;
13401 }
13402
13403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if(keepdata)
13404 {
13405 142 strcpy(sfx_string[i], tempname);
13406 142 sfx_string[i][35] = 0; //Force NULL Termination
13407 142 }
13408 142 }
13409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3173 times.
3173 else if(keepdata)
13410 {
13411 3173 sprintf(sfx_string[i],"s%03d",i);
13412
13413
2/2
✓ Branch 0 taken 2514 times.
✓ Branch 1 taken 659 times.
3173 if(i<Z35)
13414 659 strcpy(sfx_string[i], old_sfx_string[i-1]);
13415 3173 sfx_string[i][35] = 0; //Force NULL Termination
13416 3173 }
13417 3315 }
13418 13 }
13419 else
13420 {
13421 if(keepdata)
13422 {
13423 for(int32_t i=1; i<WAV_COUNT; i++)
13424 {
13425 sprintf(sfx_string[i],"s%03d",i);
13426
13427 if(i<Z35)
13428 strcpy(sfx_string[i], old_sfx_string[i-1]);
13429 }
13430 }
13431 }
13432
13433 //finally... section data
13434
2/2
✓ Branch 0 taken 3315 times.
✓ Branch 1 taken 13 times.
3328 for(int32_t i=1; i<wavcount; i++)
13435 {
13436
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 3173 times.
3315 if(get_bit(tempflag, i-1))
13437 {
13438
13439
1/2
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
142 if(!p_igetl(&dummy,f,true))
13440 {
13441 return qe_invalid;
13442 }
13443
13444 142 (temp_sample.bits) = dummy;
13445
13446
1/2
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
142 if(!p_igetl(&dummy,f,true))
13447 {
13448 return qe_invalid;
13449 }
13450
13451 142 (temp_sample.stereo) = dummy;
13452
13453
1/2
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
142 if(!p_igetl(&dummy,f,keepdata))
13454 {
13455 return qe_invalid;
13456 }
13457
13458 142 (temp_sample.freq) = dummy;
13459
13460
1/2
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
142 if(!p_igetl(&dummy,f,keepdata))
13461 {
13462 return qe_invalid;
13463 }
13464
13465 142 (temp_sample.priority) = dummy;
13466
13467
1/2
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
142 if(!p_igetl(&(temp_sample.len),f,true))
13468 {
13469 return qe_invalid;
13470 }
13471
13472
1/2
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
142 if(!p_igetl(&(temp_sample.loop_start),f,keepdata))
13473 {
13474 return qe_invalid;
13475 }
13476
13477
1/2
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
142 if(!p_igetl(&(temp_sample.loop_end),f,keepdata))
13478 {
13479 return qe_invalid;
13480 }
13481
13482
1/2
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
142 if(!p_igetl(&(temp_sample.param),f,keepdata))
13483 {
13484 return qe_invalid;
13485 }
13486
13487 // al_trace("F%i: L%i\n",i,temp_sample.len);
13488 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13489 142 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13490 142 temp_sample.data = calloc(len,1);
13491
13492
1/2
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
142 if(s_version < 3)
13493 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13494
13495 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if(s_version < 2)
13497 {
13498 if(!pfread(temp_sample.data, len,f,keepdata))
13499 {
13500 return qe_invalid;
13501 }
13502 }
13503 else
13504 {
13505 //re-endianfy the data
13506 142 int32_t wordstoread = len / sizeof(word);
13507
13508
2/2
✓ Branch 0 taken 3636134 times.
✓ Branch 1 taken 142 times.
3636276 for(int32_t j=0; j<wordstoread; j++)
13509 {
13510 word temp;
13511
13512
1/2
✓ Branch 0 taken 3636134 times.
✗ Branch 1 not taken.
3636134 if(!p_igetw(&temp, f, keepdata))
13513 {
13514 return qe_invalid;
13515 }
13516
13517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3636134 times.
3636134 if(keepdata)
13518 3636134 ((word *)temp_sample.data)[j] = temp;
13519 3636134 }
13520 }
13521 142 }
13522
2/2
✓ Branch 0 taken 659 times.
✓ Branch 1 taken 2514 times.
3173 else if(i < Z35)
13523 {
13524 659 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13525 659 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13526 659 set_bit(tempflag, i-1, 1);
13527 659 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13528 659 temp_sample.data = calloc(len,1);
13529 659 memcpy(temp_sample.data, datsamp->data, len);
13530 659 }
13531 2514 else continue;
13532
13533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 801 times.
801 if(keepdata)
13534 {
13535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 801 times.
801 if(customsfxdata[i].data!=NULL)
13536 {
13537 // delete [] customsfxdata[i].data;
13538 801 free(customsfxdata[i].data);
13539 801 }
13540
13541 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13542 801 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13543 801 customsfxdata[i].data = calloc(len2,1);
13544 801 customsfxdata[i].bits = temp_sample.bits;
13545 801 customsfxdata[i].stereo = temp_sample.stereo;
13546 801 customsfxdata[i].freq = temp_sample.freq;
13547 801 customsfxdata[i].priority = temp_sample.priority;
13548 801 customsfxdata[i].len = temp_sample.len;
13549 801 customsfxdata[i].loop_start = temp_sample.loop_start;
13550 801 customsfxdata[i].loop_end = temp_sample.loop_end;
13551 801 customsfxdata[i].param = temp_sample.param;
13552 801 int32_t cpylen = len2;
13553
13554
1/2
✓ Branch 0 taken 801 times.
✗ Branch 1 not taken.
801 if(s_version<3)
13555 {
13556 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13557 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13558 }
13559
13560 801 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13561 801 }
13562
13563 801 free(temp_sample.data);
13564 801 }
13565
13566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata)
13567 13 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13568
13569 13 sfxdat=0;
13570 13 return 0;
13571 13 }
13572
13573 13 void setupsfx()
13574 {
13575
2/2
✓ Branch 0 taken 3315 times.
✓ Branch 1 taken 13 times.
3328 for(int32_t i=1; i<WAV_COUNT; i++)
13576 {
13577 3315 sprintf(sfx_string[i],"s%03d",i);
13578
13579
2/2
✓ Branch 0 taken 2535 times.
✓ Branch 1 taken 780 times.
3315 if(i<Z35)
13580 {
13581 780 strcpy(sfx_string[i], old_sfx_string[i-1]);
13582 780 }
13583
13584 3315 memset(customsfxflag, 0, WAV_COUNT>>3);
13585
13586 3315 int32_t j=i;
13587
13588
2/2
✓ Branch 0 taken 793 times.
✓ Branch 1 taken 2522 times.
3315 if(i>Z35)
13589 {
13590 2522 i=Z35;
13591 2522 }
13592
13593 3315 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13594
13595
2/2
✓ Branch 0 taken 2805 times.
✓ Branch 1 taken 510 times.
3315 if(customsfxdata[j].data!=NULL)
13596 {
13597 // delete [] customsfxdata[j].data;
13598 510 free(customsfxdata[j].data);
13599 510 }
13600
13601 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13602 3315 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13603 3315 customsfxdata[j].bits = temp_sample->bits;
13604 3315 customsfxdata[j].stereo = temp_sample->stereo;
13605 3315 customsfxdata[j].freq = temp_sample->freq;
13606 3315 customsfxdata[j].priority = temp_sample->priority;
13607 3315 customsfxdata[j].len = temp_sample->len;
13608 3315 customsfxdata[j].loop_start = temp_sample->loop_start;
13609 3315 customsfxdata[j].loop_end = temp_sample->loop_end;
13610 3315 customsfxdata[j].param = temp_sample->param;
13611 3315 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13612 3315 i=j;
13613 3315 }
13614 13 }
13615
13616 extern char *guy_string[eMAXGUYS];
13617 extern const char *old_guy_string[OLDMAXGUYS];
13618
13619 13 int32_t readguys(PACKFILE *f, zquestheader *Header, bool keepdata)
13620 {
13621 dword dummy;
13622 word guy_cversion;
13623 13 word guyversion=0;
13624
13625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(Header->zelda_version >= 0x193)
13626 {
13627 //section version info
13628
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&guyversion,f,true))
13629 {
13630 return qe_invalid;
13631 }
13632
13633 13 FFCore.quest_format[vGuys] = guyversion;
13634
13635 //al_trace("Guys version %d\n", guyversion);
13636
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&guy_cversion,f,true))
13637 {
13638 return qe_invalid;
13639 }
13640 13 al_trace("Guy CVersion is: %d\n", guy_cversion);
13641 //section size
13642
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy,f,true))
13643 {
13644 return qe_invalid;
13645 }
13646 13 }
13647
13648
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(guyversion > 3)
13649 {
13650
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 13 times.
6669 for(int32_t i=0; i<MAXGUYS; i++)
13651 {
13652 char tempname[64];
13653
13654 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13655 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13656
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6656 if(guyversion < 23 && i >= OLDBETAMAXGUYS && keepdata)
13657 {
13658 memset(tempname, 0, sizeof(char)*64);
13659 sprintf(tempname, "e%03d", i);
13660 strcpy(guy_string[i], tempname);
13661
13662 continue;
13663 }
13664
13665
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!pfread(tempname, 64, f, keepdata))
13666 {
13667 return qe_invalid;
13668 }
13669
13670 // Don't retain names of uneditable enemy entries!
13671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
6656 if(keepdata)
13672 {
13673 // for version upgrade to 2.5
13674
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6656 if(guyversion < 23 && i >= 177)
13675 {
13676 // some of the older builds have names such as 'zz123',
13677 // (this order gets messed up with some eXXX and some zzXXX)
13678 // so let's update to the newer naming convection. -Gleeok
13679 char tmpbuf[64];
13680 memset(tmpbuf, 0, sizeof(char)*64);
13681 sprintf(tmpbuf, "zz%03d", i);
13682
13683 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13684 {
13685 memset(tempname, 0, sizeof(char)*64);
13686 sprintf(tempname, "e%03d", i);
13687 }
13688 }
13689
13690
6/6
✓ Branch 0 taken 2301 times.
✓ Branch 1 taken 4355 times.
✓ Branch 2 taken 2184 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 1767 times.
✓ Branch 5 taken 417 times.
6656 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13691 {
13692 6239 strcpy(guy_string[i], tempname);
13693 6239 }
13694 else
13695 {
13696 417 strcpy(guy_string[i],old_guy_string[i]);
13697 }
13698 6656 }
13699 6656 }
13700 13 }
13701 else
13702 {
13703 if(keepdata)
13704 {
13705 for(int32_t i=0; i<eMAXGUYS; i++)
13706 {
13707 sprintf(guy_string[i],"zz%03d",i);
13708 }
13709
13710 for(int32_t i=0; i<OLDMAXGUYS; i++)
13711 {
13712 strcpy(guy_string[i],old_guy_string[i]);
13713 }
13714 }
13715 }
13716
13717
13718 //finally... section data
13719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata)
13720 {
13721 13 init_guys(guyversion); //using default data for now...
13722
13723 // Goriya guy fix
13724
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13725 {
13726 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13727 {
13728 guysbuf[gGORIYA].tile=130;
13729 guysbuf[gGORIYA].e_tile=130;
13730 }
13731 }
13732 13 }
13733
13734
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Header->zelda_version < 0x193)
13735 {
13736 if(get_bit(deprecated_rules,46))
13737 {
13738 guysbuf[eDODONGO].cset=14;
13739 guysbuf[eDODONGO].bosspal=spDIG;
13740 }
13741 }
13742 // Not sure when this first changed, but it's necessary for 2.10, at least
13743 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13744 //2.10 Fixes
13745
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13746 {
13747 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13748 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13749 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13750 guysbuf[eCENT1].misc3 = 1;
13751 guysbuf[eCENT2].misc3 = 1;
13752 }
13753
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13754 {
13755 13 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13756 13 }
13757
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Header->zelda_version <= 0x210)
13758 {
13759 guysbuf[eGLEEOK1F].misc6 = 16;
13760 guysbuf[eGLEEOK2F].misc6 = 16;
13761 guysbuf[eGLEEOK3F].misc6 = 16;
13762 guysbuf[eGLEEOK4F].misc6 = 16;
13763
13764 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13765 guysbuf[eBATROBE].misc4 = 1;
13766 //guysbuf[eSUMMONER].misc4 = 1;
13767 guysbuf[eWWIZ].misc4 = 1;
13768 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13769 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13770 }
13771
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Header->zelda_version == 0x190)
13772 {
13773 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13774 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13775 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13776 }
13777
13778 // The versions here may not be correct
13779 // zelda_version>=0x211 handled at guyversion<24
13780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(Header->zelda_version <= 0x190)
13781 {
13782 guysbuf[eCENT1].misc3 = 0;
13783 guysbuf[eCENT2].misc3 = 0;
13784 guysbuf[eMOLDORM].misc2 = 0;
13785 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13786 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13787 }
13788
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 else if(Header->zelda_version <= 0x210)
13789 {
13790 guysbuf[eCENT1].misc3 = 1;
13791 guysbuf[eCENT2].misc3 = 1;
13792 guysbuf[eMOLDORM].misc2 = 0;
13793 }
13794
13795
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13796 {
13797 guysbuf[eKEESE1].misc16 = 120;
13798 guysbuf[eKEESE2].misc16 = 120;
13799 guysbuf[eKEESE3].misc16 = 120;
13800 guysbuf[eKEESETRIB].misc16 = 120;
13801 guysbuf[eKEESE1].misc17 = 16;
13802 guysbuf[eKEESE2].misc17 = 16;
13803 guysbuf[eKEESE3].misc17 = 16;
13804 guysbuf[eKEESETRIB].misc17 = 16;
13805
13806 guysbuf[ePEAHAT].misc16 = 80;
13807 guysbuf[ePEAHAT].misc17 = 16;
13808
13809 guysbuf[eGHINI2].misc16 = 120;
13810 guysbuf[eGHINI2].misc17 = 10;
13811
13812 }
13813
13814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(guyversion<=2)
13815 {
13816 return readherosprites2(f, guyversion==2?0:-1, 0, keepdata);
13817 }
13818
13819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(guyversion > 3)
13820 {
13821 guydata tempguy;
13822
13823
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 13 times.
6669 for(int32_t i=0; i<MAXGUYS; i++)
13824 {
13825
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6656 if(guyversion < 23 && keepdata) // May 2012 : 512 max enemies
13826 {
13827 if(i >= OLDBETAMAXGUYS)
13828 {
13829 memset(&guysbuf[i], 0, sizeof(guydata));
13830 continue;
13831 }
13832 }
13833
13834 6656 memset(&tempguy, 0, sizeof(guydata));
13835
13836
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetl(&(tempguy.flags),f,keepdata))
13837 {
13838 return qe_invalid;
13839 }
13840
13841
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetl(&(tempguy.flags2),f,keepdata))
13842 {
13843 return qe_invalid;
13844 }
13845
13846
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if ( guyversion >= 36 ) //expanded tiles
13847 {
13848
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.tile),f,keepdata))
13849 {
13850 return qe_invalid;
13851 }
13852 1024 }
13853 else
13854 {
13855
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&(tempguy.tile),f,keepdata))
13856 {
13857 return qe_invalid;
13858 }
13859 }
13860
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&(tempguy.width),f,keepdata))
13861 {
13862 return qe_invalid;
13863 }
13864
13865
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&(tempguy.height),f,keepdata))
13866 {
13867 return qe_invalid;
13868 }
13869
13870
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if ( guyversion >= 36 ) //expanded tiles
13871 {
13872
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.s_tile),f,keepdata))
13873 {
13874 return qe_invalid;
13875 }
13876 1024 }
13877 else
13878 {
13879
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&(tempguy.s_tile),f,keepdata))
13880 {
13881 return qe_invalid;
13882 }
13883 }
13884
13885
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&(tempguy.s_width),f,keepdata))
13886 {
13887 return qe_invalid;
13888 }
13889
13890
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&(tempguy.s_height),f,keepdata))
13891 {
13892 return qe_invalid;
13893 }
13894
13895
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if ( guyversion >= 36 ) //expanded tiles
13896 {
13897
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.e_tile),f,keepdata))
13898 {
13899 return qe_invalid;
13900 }
13901 1024 }
13902 else
13903 {
13904
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 if(!p_igetw(&(tempguy.e_tile),f,keepdata))
13905 {
13906 return qe_invalid;
13907 }
13908 }
13909
13910
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&(tempguy.e_width),f,keepdata))
13911 {
13912 return qe_invalid;
13913 }
13914
13915
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&(tempguy.e_height),f,keepdata))
13916 {
13917 return qe_invalid;
13918 }
13919
13920
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.hp),f,keepdata))
13921 {
13922 return qe_invalid;
13923 }
13924
13925
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.family),f,keepdata))
13926 {
13927 return qe_invalid;
13928 }
13929
13930
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
6656 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13931 {
13932 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13933 {
13934 tempguy.s_tile=tempguy.e_tile+120;
13935 tempguy.s_width=tempguy.e_width;
13936 tempguy.s_height=tempguy.e_height;
13937 }
13938 else tempguy.s_tile=860;
13939 }
13940
13941
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.cset),f,keepdata))
13942 {
13943 return qe_invalid;
13944 }
13945
13946
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.anim),f,keepdata))
13947 {
13948 return qe_invalid;
13949 }
13950
13951
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.e_anim),f,keepdata))
13952 {
13953 return qe_invalid;
13954 }
13955
13956
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.frate),f,keepdata))
13957 {
13958 return qe_invalid;
13959 }
13960
13961
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.e_frate),f,keepdata))
13962 {
13963 return qe_invalid;
13964 }
13965
13966
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion < 13) // April 2009
13967 {
13968 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13969 {
13970 tempguy.frate *= 2;
13971 tempguy.e_frate *= 2;
13972 }
13973 }
13974
13975
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion < 14) // May 1 2009
13976 {
13977 if(tempguy.anim==a2FRMSLOW)
13978 {
13979 tempguy.anim=a2FRM;
13980 tempguy.frate *= 2;
13981 }
13982
13983 if(tempguy.e_anim==a2FRMSLOW)
13984 {
13985 tempguy.e_anim=a2FRM;
13986 tempguy.e_frate *= 2;
13987 }
13988
13989 if(tempguy.anim==aFLIPSLOW)
13990 {
13991 tempguy.anim=aFLIP;
13992 tempguy.frate *= 2;
13993 }
13994
13995 if(tempguy.e_anim==aFLIPSLOW)
13996 {
13997 tempguy.e_anim=aFLIP;
13998 tempguy.e_frate *= 2;
13999 }
14000
14001 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14002
14003 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14004
14005 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14006 {
14007 tempguy.anim=a4FRM4DIR;
14008 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14009 }
14010
14011 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14012 {
14013 tempguy.e_anim=a4FRM4DIR;
14014 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14015 }
14016 }
14017
14018
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.dp),f,keepdata))
14019 {
14020 return qe_invalid;
14021 }
14022
14023 //correction for guy fire
14024
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion < 6)
14025 {
14026 if(i == gFIRE)
14027 tempguy.dp = 2;
14028 }
14029
14030
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.wdp),f,keepdata))
14031 {
14032 return qe_invalid;
14033 }
14034
14035
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.weapon),f,keepdata))
14036 {
14037 return qe_invalid;
14038 }
14039
14040 //correction for bosses using triple, "rising" fireballs
14041
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion < 5)
14042 {
14043 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14044 i == eGOHMA3 || i == eGOHMA4)
14045 {
14046 if(tempguy.weapon == ewFireball)
14047 tempguy.weapon = ewFireball2;
14048 }
14049 }
14050
14051
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.rate),f,keepdata))
14052 {
14053 return qe_invalid;
14054 }
14055
14056
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.hrate),f,keepdata))
14057 {
14058 return qe_invalid;
14059 }
14060
14061
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.step),f,keepdata))
14062 {
14063 return qe_invalid;
14064 }
14065
14066 // HIGHLY UNORTHODOX UPDATING THING, part 2
14067
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6656 if(fixpolsvoice && tempguy.family==eePOLSV)
14068 {
14069 tempguy.step /= 2;
14070 }
14071
14072
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.homing),f,keepdata))
14073 {
14074 return qe_invalid;
14075 }
14076
14077
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.grumble),f,keepdata))
14078 {
14079 return qe_invalid;
14080 }
14081
14082
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.item_set),f,keepdata))
14083 {
14084 return qe_invalid;
14085 }
14086
14087
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14088 {
14089
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetl(&(tempguy.misc1),f,keepdata))
14090 {
14091 return qe_invalid;
14092 }
14093
14094
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetl(&(tempguy.misc2),f,keepdata))
14095 {
14096 return qe_invalid;
14097 }
14098
14099
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetl(&(tempguy.misc3),f,keepdata))
14100 {
14101 return qe_invalid;
14102 }
14103
14104
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetl(&(tempguy.misc4),f,keepdata))
14105 {
14106 return qe_invalid;
14107 }
14108
14109
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetl(&(tempguy.misc5),f,keepdata))
14110 {
14111 return qe_invalid;
14112 }
14113
14114
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetl(&(tempguy.misc6),f,keepdata))
14115 {
14116 return qe_invalid;
14117 }
14118
14119
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetl(&(tempguy.misc7),f,keepdata))
14120 {
14121 return qe_invalid;
14122 }
14123
14124
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetl(&(tempguy.misc8),f,keepdata))
14125 {
14126 return qe_invalid;
14127 }
14128
14129
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetl(&(tempguy.misc9),f,keepdata))
14130 {
14131 return qe_invalid;
14132 }
14133
14134
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetl(&(tempguy.misc10),f,keepdata))
14135 {
14136 return qe_invalid;
14137 }
14138 6656 }
14139 else
14140 {
14141 int16_t tempMisc;
14142
14143 if(!p_igetw(&tempMisc,f,keepdata))
14144 {
14145 return qe_invalid;
14146 }
14147
14148 tempguy.misc1=tempMisc;
14149
14150 if(!p_igetw(&tempMisc,f,keepdata))
14151 {
14152 return qe_invalid;
14153 }
14154
14155 tempguy.misc2=tempMisc;
14156
14157 if(!p_igetw(&tempMisc,f,keepdata))
14158 {
14159 return qe_invalid;
14160 }
14161
14162 tempguy.misc3=tempMisc;
14163
14164 if(!p_igetw(&tempMisc,f,keepdata))
14165 {
14166 return qe_invalid;
14167 }
14168
14169 tempguy.misc4=tempMisc;
14170
14171 if(!p_igetw(&tempMisc,f,keepdata))
14172 {
14173 return qe_invalid;
14174 }
14175
14176 tempguy.misc5=tempMisc;
14177
14178 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14179 {
14180 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14181 tempguy.misc5 = 74;
14182 }
14183
14184 if(!p_igetw(&tempMisc,f,keepdata))
14185 {
14186 return qe_invalid;
14187 }
14188
14189 tempguy.misc6=tempMisc;
14190
14191 if(!p_igetw(&tempMisc,f,keepdata))
14192 {
14193 return qe_invalid;
14194 }
14195
14196 tempguy.misc7=tempMisc;
14197
14198 if(!p_igetw(&tempMisc,f,keepdata))
14199 {
14200 return qe_invalid;
14201 }
14202
14203 tempguy.misc8=tempMisc;
14204
14205 if(!p_igetw(&tempMisc,f,keepdata))
14206 {
14207 return qe_invalid;
14208 }
14209
14210 tempguy.misc9=tempMisc;
14211
14212 if(!p_igetw(&tempMisc,f,keepdata))
14213 {
14214 return qe_invalid;
14215 }
14216
14217 tempguy.misc10=tempMisc;
14218 }
14219
14220
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.bgsfx),f,keepdata))
14221 {
14222 return qe_invalid;
14223 }
14224
14225
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.bosspal),f,keepdata))
14226 {
14227 return qe_invalid;
14228 }
14229
14230
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetw(&(tempguy.extend),f,keepdata))
14231 {
14232 return qe_invalid;
14233 }
14234
14235 //! Enemy Defences
14236
14237 //If a 2.50 quest, use only the 2.5 defences.
14238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
6656 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14239 {
14240
2/2
✓ Branch 0 taken 126464 times.
✓ Branch 1 taken 6656 times.
133120 for(int32_t j=0; j<edefLAST; j++)
14241 {
14242
1/2
✓ Branch 0 taken 126464 times.
✗ Branch 1 not taken.
126464 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14243 {
14244 return qe_invalid;
14245 }
14246 126464 }
14247 //then copy the generic script defence to all the new script defences
14248
14249 6656 }
14250
14251
14252
14253
14254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
6656 if(guyversion >= 18)
14255 {
14256
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&(tempguy.hitsfx),f,keepdata))
14257 {
14258 return qe_invalid;
14259 }
14260
14261
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_getc(&(tempguy.deadsfx),f,keepdata))
14262 {
14263 return qe_invalid;
14264 }
14265 6656 }
14266
14267
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion >= 22)
14268 {
14269
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetl(&(tempguy.misc11),f,keepdata))
14270 {
14271 return qe_invalid;
14272 }
14273
14274
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetl(&(tempguy.misc12),f,keepdata))
14275 {
14276 return qe_invalid;
14277 }
14278 6656 }
14279 else if(guyversion >= 19)
14280 {
14281 int16_t tempMisc;
14282
14283 if(!p_igetw(&tempMisc,f,keepdata))
14284 {
14285 return qe_invalid;
14286 }
14287
14288 tempguy.misc11=tempMisc;
14289
14290 if(!p_igetw(&tempMisc,f,keepdata))
14291 {
14292 return qe_invalid;
14293 }
14294
14295 tempguy.misc12=tempMisc;
14296 }
14297
14298 //If a 2.54 or later quest, use all of the defences.
14299
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
6656 if(guyversion > 24) // Add new guyversion conditional statement
14300 {
14301
2/2
✓ Branch 0 taken 22528 times.
✓ Branch 1 taken 1024 times.
23552 for(int32_t j=edefLAST; j<edefLAST255; j++)
14302 {
14303
1/2
✓ Branch 0 taken 22528 times.
✗ Branch 1 not taken.
22528 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14304 {
14305 return qe_invalid;
14306 }
14307 22528 }
14308 1024 }
14309
14310
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14311 {
14312
2/2
✓ Branch 0 taken 56320 times.
✓ Branch 1 taken 5632 times.
61952 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14313 {
14314 56320 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14315 56320 }
14316 5632 }
14317
14318 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14319
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
6656 if(guyversion > 25)
14320 {
14321
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.txsz),f,keepdata))
14322 {
14323 return qe_invalid;
14324 }
14325
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.tysz),f,keepdata))
14326 {
14327 return qe_invalid;
14328 }
14329
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.hxsz),f,keepdata))
14330 {
14331 return qe_invalid;
14332 }
14333
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.hysz),f,keepdata))
14334 {
14335 return qe_invalid;
14336 }
14337
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.hzsz),f,keepdata))
14338 {
14339 return qe_invalid;
14340 }
14341 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14342
14343 */
14344 1024 }
14345 //More Enemy Editor vars for 2.60
14346
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
6656 if(guyversion > 26)
14347 {
14348
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.hxofs),f,keepdata))
14349 {
14350 return qe_invalid;
14351 }
14352
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.hyofs),f,keepdata))
14353 {
14354 return qe_invalid;
14355 }
14356
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.xofs),f,keepdata))
14357 {
14358 return qe_invalid;
14359 }
14360
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.yofs),f,keepdata))
14361 {
14362 return qe_invalid;
14363 }
14364
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.zofs),f,keepdata))
14365 {
14366 return qe_invalid;
14367 }
14368 1024 }
14369
14370
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14371 {
14372 5632 tempguy.wpnsprite = 0;
14373 5632 }
14374
14375
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
6656 if(guyversion > 27)
14376 {
14377
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.wpnsprite),f,keepdata))
14378 {
14379 return qe_invalid;
14380 }
14381 1024 }
14382
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14383 {
14384 5632 tempguy.SIZEflags = 0;
14385 5632 }
14386
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
6656 if(guyversion > 28)
14387 {
14388
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.SIZEflags),f,keepdata))
14389 {
14390 return qe_invalid;
14391 }
14392
14393 1024 }
14394
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14395 {
14396 5632 tempguy.frozentile = 0;
14397 5632 tempguy.frozencset = 0;
14398 5632 tempguy.frozenclock = 0;
14399
2/2
✓ Branch 0 taken 56320 times.
✓ Branch 1 taken 5632 times.
61952 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14400 5632 }
14401
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
6656 if(guyversion >= 30)
14402 {
14403
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.frozentile),f,keepdata))
14404 {
14405 return qe_invalid;
14406 }
14407
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.frozencset),f,keepdata))
14408 {
14409 return qe_invalid;
14410 }
14411
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.frozenclock),f,keepdata))
14412 {
14413 return qe_invalid;
14414 }
14415
2/2
✓ Branch 0 taken 10240 times.
✓ Branch 1 taken 1024 times.
11264 for ( int32_t q = 0; q < 10; q++ ) {
14416
1/2
✓ Branch 0 taken 10240 times.
✗ Branch 1 not taken.
10240 if(!p_igetw(&(tempguy.frozenmisc[q]),f,keepdata))
14417 {
14418 return qe_invalid;
14419 }
14420 10240 }
14421
14422 1024 }
14423
14424
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
6656 if(guyversion >= 34)
14425 {
14426
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetw(&(tempguy.firesfx),f,keepdata))
14427 {
14428 return qe_invalid;
14429 }
14430
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc16),f,keepdata))
14431 {
14432 return qe_invalid;
14433 }
14434
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc17),f,keepdata))
14435 {
14436 return qe_invalid;
14437 }
14438
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc18),f,keepdata))
14439 {
14440 return qe_invalid;
14441 }
14442
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc19),f,keepdata))
14443 {
14444 return qe_invalid;
14445 }
14446
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc20),f,keepdata))
14447 {
14448 return qe_invalid;
14449 }
14450
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc21),f,keepdata))
14451 {
14452 return qe_invalid;
14453 }
14454
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc22),f,keepdata))
14455 {
14456 return qe_invalid;
14457 }
14458
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc23),f,keepdata))
14459 {
14460 return qe_invalid;
14461 }
14462
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc24),f,keepdata))
14463 {
14464 return qe_invalid;
14465 }
14466
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc25),f,keepdata))
14467 {
14468 return qe_invalid;
14469 }
14470
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc26),f,keepdata))
14471 {
14472 return qe_invalid;
14473 }
14474
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc27),f,keepdata))
14475 {
14476 return qe_invalid;
14477 }
14478
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc28),f,keepdata))
14479 {
14480 return qe_invalid;
14481 }
14482
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc29),f,keepdata))
14483 {
14484 return qe_invalid;
14485 }
14486
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc30),f,keepdata))
14487 {
14488 return qe_invalid;
14489 }
14490
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc31),f,keepdata))
14491 {
14492 return qe_invalid;
14493 }
14494
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc32),f,keepdata))
14495 {
14496 return qe_invalid;
14497 }
14498
14499
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 1024 times.
33792 for ( int32_t q = 0; q < 32; q++ ) {
14500
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if(!p_igetl(&(tempguy.movement[q]),f,keepdata))
14501 {
14502 return qe_invalid;
14503 }
14504 32768 }
14505
2/2
✓ Branch 0 taken 32768 times.
✓ Branch 1 taken 1024 times.
33792 for ( int32_t q = 0; q < 32; q++ ) {
14506
1/2
✓ Branch 0 taken 32768 times.
✗ Branch 1 not taken.
32768 if(!p_igetl(&(tempguy.new_weapon[q]),f,keepdata))
14507 {
14508 return qe_invalid;
14509 }
14510 32768 }
14511
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetw(&(tempguy.script),f,keepdata))
14512 {
14513 return qe_invalid;
14514 }
14515 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14516
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 1024 times.
9216 for ( int32_t q = 0; q < 8; q++ )
14517 {
14518
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(!p_igetl(&(tempguy.initD[q]),f,keepdata))
14519 {
14520 return qe_invalid;
14521 }
14522 8192 }
14523
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 1024 times.
3072 for ( int32_t q = 0; q < 2; q++ )
14524 {
14525
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if(!p_igetl(&(tempguy.initA[q]),f,keepdata))
14526 {
14527 return qe_invalid;
14528 }
14529 2048 }
14530
14531 1024 }
14532
14533
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
6656 if(guyversion >= 37)
14534 {
14535
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.editorflags),f,keepdata))
14536 {
14537 return qe_invalid;
14538 }
14539 1024 }
14540
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14541
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
6656 if(guyversion >= 38)
14542 {
14543
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc13),f,keepdata))
14544 {
14545 return qe_invalid;
14546 }
14547
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc14),f,keepdata))
14548 {
14549 return qe_invalid;
14550 }
14551
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.misc15),f,keepdata))
14552 {
14553 return qe_invalid;
14554 }
14555
14556 1024 }
14557
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if ( guyversion < 38 )
14558 {
14559 5632 tempguy.misc13 = 0;
14560 5632 tempguy.misc14 = 0;
14561 5632 tempguy.misc15 = 0;
14562 5632 }
14563
14564
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
6656 if ( guyversion >= 39 )
14565 {
14566
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 1024 times.
9216 for ( int32_t q = 0; q < 8; q++ )
14567 {
14568
2/2
✓ Branch 0 taken 532480 times.
✓ Branch 1 taken 8192 times.
540672 for ( int32_t w = 0; w < 65; w++ )
14569 {
14570
1/2
✓ Branch 0 taken 532480 times.
✗ Branch 1 not taken.
532480 if(!p_getc(&(tempguy.initD_label[q][w]),f,keepdata))
14571 {
14572 return qe_invalid;
14573 }
14574 532480 }
14575
2/2
✓ Branch 0 taken 532480 times.
✓ Branch 1 taken 8192 times.
540672 for ( int32_t w = 0; w < 65; w++ )
14576 {
14577
1/2
✓ Branch 0 taken 532480 times.
✗ Branch 1 not taken.
532480 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f,keepdata))
14578 {
14579 return qe_invalid;
14580 }
14581 532480 }
14582 8192 }
14583
14584
14585 1024 }
14586
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if ( guyversion < 39 ) //apply old InitD strings to both
14587 {
14588 5632 al_trace("Populating InitD Label Fields for NPCS\n");
14589
2/2
✓ Branch 0 taken 45056 times.
✓ Branch 1 taken 5632 times.
50688 for ( int32_t q = 0; q < 8; q++ )
14590 {
14591 45056 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14592 45056 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14593 45056 }
14594 5632 }
14595
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
6656 if ( guyversion >= 40 )
14596 {
14597
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetw(&(tempguy.weaponscript),f,keepdata))
14598 {
14599 return qe_invalid;
14600 }
14601 1024 }
14602
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if ( guyversion < 40 )
14603 {
14604 5632 tempguy.weaponscript = 0;
14605 5632 }
14606 //eweapon script InitD
14607
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
6656 if ( guyversion >= 41 )
14608 {
14609
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 1024 times.
9216 for ( int32_t q = 0; q < 8; q++ )
14610 {
14611
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(!p_igetl(&(tempguy.weap_initiald[q]),f,keepdata))
14612 {
14613 return qe_invalid;
14614 }
14615 8192 }
14616
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if ( guy_cversion < 4 )
14617 {
14618 if ( tempguy.family == eeKEESE )
14619 {
14620
14621 if ( !tempguy.misc1 )
14622 {
14623 tempguy.misc16 = 120;
14624 tempguy.misc17 = 16;
14625
14626 }
14627 }
14628 if ( tempguy.family == eePEAHAT )
14629 {
14630 tempguy.misc16 = 80;
14631 tempguy.misc17 = 16;
14632 }
14633
14634 if ( tempguy.family == eeGHINI )
14635 {
14636 tempguy.misc16 = 120;
14637 tempguy.misc17 = 10;
14638 }
14639
14640 }
14641 1024 }
14642
14643
14644
14645 //default weapon sprites (quest version < 2.54)
14646 //port over old defaults -Z
14647
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if(guyversion < 32)
14648 {
14649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5632 times.
5632 if ( tempguy.wpnsprite <= 0 )
14650 {
14651
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4863 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 98 times.
✓ Branch 7 taken 61 times.
✓ Branch 8 taken 103 times.
✓ Branch 9 taken 11 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 21 times.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 48 times.
✓ Branch 14 taken 97 times.
✓ Branch 15 taken 13 times.
✓ Branch 16 taken 11 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 82 times.
5632 switch(tempguy.weapon)
14652 {
14653 case wNone:
14654 4863 tempguy.wpnsprite = 0; break;
14655
14656 case wSword:
14657 case wBeam:
14658 case wBrang:
14659 case wBomb:
14660 case wSBomb:
14661 case wLitBomb:
14662 case wLitSBomb:
14663 case wArrow:
14664 case wFire:
14665 case wWhistle:
14666 case wBait:
14667 case wWand:
14668 case wMagic:
14669 case wCatching:
14670 case wWind:
14671 case wRefMagic:
14672 case wRefFireball:
14673 case wRefRock:
14674 case wHammer:
14675 case wHookshot:
14676 case wHSHandle:
14677 case wHSChain:
14678 case wSSparkle:
14679 case wFSparkle:
14680 case wSmack:
14681 case wPhantom:
14682 case wCByrna:
14683 case wRefBeam:
14684 case wStomp:
14685 case lwMax:
14686 case wScript1:
14687 case wScript2:
14688 case wScript3:
14689 case wScript4:
14690 case wScript5:
14691 case wScript6:
14692 case wScript7:
14693 case wScript8:
14694 case wScript9:
14695 case wScript10:
14696 case wIce:
14697 //Cannot use any of these weapons yet.
14698 tempguy.wpnsprite = -1;
14699 break;
14700
14701 case wEnemyWeapons:
14702 148 case ewFireball: tempguy.wpnsprite = 17; break;
14703
14704 37 case ewArrow: tempguy.wpnsprite = 19; break;
14705 37 case ewBrang: tempguy.wpnsprite = 4; break;
14706 98 case ewSword: tempguy.wpnsprite = 20; break;
14707 61 case ewRock: tempguy.wpnsprite = 18; break;
14708 103 case ewMagic: tempguy.wpnsprite = 21; break;
14709 11 case ewBomb: tempguy.wpnsprite = 78; break;
14710 1 case ewSBomb: tempguy.wpnsprite = 79; break;
14711 21 case ewLitBomb: tempguy.wpnsprite = 76; break;
14712 1 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14713 48 case ewFireTrail: tempguy.wpnsprite = 80; break;
14714 97 case ewFlame: tempguy.wpnsprite = 35; break;
14715 13 case ewWind: tempguy.wpnsprite = 36; break;
14716 11 case ewFlame2: tempguy.wpnsprite = 81; break;
14717 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14718 case ewIce: tempguy.wpnsprite = 83; break;
14719 82 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14720
14721
14722 default: break; //No assign.
14723 }
14724 5632 }
14725 5632 }
14726
14727 //default weapon fire sound (quest version < 2.54)
14728 //port over old defaults and zero new data. -Z
14729
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if(guyversion < 34)
14730 {
14731
2/2
✓ Branch 0 taken 180224 times.
✓ Branch 1 taken 5632 times.
185856 for ( int32_t q = 0; q < 32; q++ )
14732 {
14733 180224 tempguy.movement[q] = 0;
14734 180224 tempguy.new_weapon[q] = 0;
14735
14736 180224 }
14737
14738 //NPC Script attributes.
14739 5632 tempguy.script = 0; //No scripted enemies existed. -Z
14740
2/2
✓ Branch 0 taken 45056 times.
✓ Branch 1 taken 5632 times.
50688 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14741
2/2
✓ Branch 0 taken 11264 times.
✓ Branch 1 taken 5632 times.
16896 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14742
14743 5632 tempguy.misc16 = 0;
14744 5632 tempguy.misc17 = 0;
14745 5632 tempguy.misc18 = 0;
14746 5632 tempguy.misc19 = 0;
14747 5632 tempguy.misc20 = 0;
14748 5632 tempguy.misc21 = 0;
14749 5632 tempguy.misc22 = 0;
14750 5632 tempguy.misc23 = 0;
14751 5632 tempguy.misc24 = 0;
14752 5632 tempguy.misc25 = 0;
14753 5632 tempguy.misc26 = 0;
14754 5632 tempguy.misc27 = 0;
14755 5632 tempguy.misc28 = 0;
14756 5632 tempguy.misc29 = 0;
14757 5632 tempguy.misc30 = 0;
14758 5632 tempguy.misc31 = 0;
14759 5632 tempguy.misc32 = 0;
14760
14761 //old default sounds
14762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5632 times.
5632 if ( tempguy.firesfx <= 0 )
14763 {
14764
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 148 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4863 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 98 times.
✓ Branch 7 taken 61 times.
✓ Branch 8 taken 103 times.
✓ Branch 9 taken 11 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 21 times.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 48 times.
✓ Branch 14 taken 97 times.
✓ Branch 15 taken 13 times.
✓ Branch 16 taken 11 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 82 times.
5632 switch(tempguy.weapon)
14765 {
14766 case wNone:
14767 4863 tempguy.firesfx = 0; break;
14768
14769 case wSword:
14770 case wBeam:
14771 case wBrang:
14772 case wBomb:
14773 case wSBomb:
14774 case wLitBomb:
14775 case wLitSBomb:
14776 case wArrow:
14777 case wFire:
14778 case wWhistle:
14779 case wBait:
14780 case wWand:
14781 case wMagic:
14782 case wCatching:
14783 case wWind:
14784 case wRefMagic:
14785 case wRefFireball:
14786 case wRefRock:
14787 case wHammer:
14788 case wHookshot:
14789 case wHSHandle:
14790 case wHSChain:
14791 case wSSparkle:
14792 case wFSparkle:
14793 case wSmack:
14794 case wPhantom:
14795 case wCByrna:
14796 case wRefBeam:
14797 case wStomp:
14798 case lwMax:
14799 case wScript1:
14800 case wScript2:
14801 case wScript3:
14802 case wScript4:
14803 case wScript5:
14804 case wScript6:
14805 case wScript7:
14806 case wScript8:
14807 case wScript9:
14808 case wScript10:
14809 case wIce:
14810 //Cannot use any of these weapons yet.
14811 tempguy.firesfx = -1;
14812 break;
14813
14814 case wEnemyWeapons:
14815 148 case ewFireball: tempguy.firesfx = 40; break;
14816
14817 37 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14818 37 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14819 98 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14820 61 case ewRock: tempguy.firesfx = 51; break;
14821 103 case ewMagic: tempguy.firesfx = 32; break;
14822 11 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14823 1 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14824 21 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14825 1 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14826 48 case ewFireTrail: tempguy.firesfx = 13; break;
14827 97 case ewFlame: tempguy.firesfx = 13; break;
14828 13 case ewWind: tempguy.firesfx = 32; break;
14829 11 case ewFlame2: tempguy.firesfx = 13; break;
14830 case ewFlame2Trail: tempguy.firesfx = 13; break;
14831 case ewIce: tempguy.firesfx = 44; break;
14832 82 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14833
14834 //what about special attacks (e.g. summoning == 56)
14835 default: break; //No assign.
14836 }
14837 5632 }
14838 5632 }
14839
14840 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14841
4/6
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
✓ Branch 2 taken 1024 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1024 times.
6656 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14842 {
14843
2/2
✓ Branch 0 taken 322 times.
✓ Branch 1 taken 5310 times.
5632 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14844 5632 }
14845 //Keese and bat halt rates.
14846
3/4
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5632 times.
6656 if ( guyversion < 42 && guy_cversion < 4 )
14847 {
14848
14849
2/2
✓ Branch 0 taken 5570 times.
✓ Branch 1 taken 62 times.
5632 if ( tempguy.family == eeKEESE )
14850 {
14851
14852
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 45 times.
62 if ( !tempguy.misc1 )
14853 {
14854 45 tempguy.misc16 = 120;
14855 45 tempguy.misc17 = 16;
14856
14857 45 }
14858 62 }
14859
2/2
✓ Branch 0 taken 5609 times.
✓ Branch 1 taken 23 times.
5632 if ( tempguy.family == eePEAHAT )
14860 {
14861 23 tempguy.misc16 = 80;
14862 23 tempguy.misc17 = 16;
14863 23 }
14864
2/2
✓ Branch 0 taken 5621 times.
✓ Branch 1 taken 11 times.
5632 if ( tempguy.family == eeGHINI )
14865 {
14866 11 tempguy.misc16 = 120;
14867 11 tempguy.misc17 = 10;
14868 11 }
14869
14870
14871 5632 }
14872
14873
14874 //miscellaneous other corrections
14875 //fix the mirror wizzrobe -DD
14876
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion < 7)
14877 {
14878 if(i == eMWIZ)
14879 {
14880 tempguy.misc2 = 0;
14881 tempguy.misc4 = 1;
14882 }
14883 }
14884
14885
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion < 8)
14886 {
14887 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14888 {
14889 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14890 tempguy.misc5 = 4; //neck length in segments
14891 tempguy.misc6 = 8; //neck offset from first body tile
14892 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14893 tempguy.misc8 = 168; //head offset from first body tile
14894 tempguy.misc9 = 228; //flying head offset from first body tile
14895
14896 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14897 {
14898 tempguy.misc6 += 10; //neck offset from first body tile
14899 tempguy.misc8 -= 12; //head offset from first body tile
14900 }
14901 }
14902 }
14903
14904
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14905 {
14906 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14907 tempguy.bosspal = spDIG;
14908 }
14909
14910
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion < 11) // December 2007 - Spinning Tile fix
14911 {
14912 if(tempguy.family==eeSPINTILE)
14913 {
14914 tempguy.flags |= guy_superman;
14915 tempguy.item_set = 0; // Don't drop items
14916 tempguy.step = 300;
14917 }
14918 }
14919
14920
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14921 {
14922 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14923 {
14924 if(tempguy.family==eeROPE)
14925 {
14926 tempguy.flags2 &= ~guy_flashing;
14927 }
14928 }
14929
14930 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14931 {
14932 if(tempguy.family==eeBUBBLE)
14933 {
14934 tempguy.flags2 &= ~guy_flashing;
14935 }
14936 }
14937
14938 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14939 {
14940 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14941 {
14942 tempguy.flags2 |= guy_blinking;
14943 }
14944
14945 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14946 {
14947 tempguy.flags2 |= guy_transparent;
14948 }
14949 }
14950 }
14951
14952
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14953 {
14954 if(i==gFIRE)
14955 {
14956 tempguy.e_anim = aFLIP;
14957 tempguy.e_frate = 24;
14958 }
14959
14960 if(i==gFAIRY)
14961 {
14962 tempguy.e_anim = a2FRM;
14963 tempguy.e_frate = 16;
14964 }
14965 }
14966
14967
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14968 {
14969 if(i==0) Z_message("Updating guys to version 16...\n");
14970
14971 update_guy_1(&tempguy);
14972
14973 if(i==eMPOLSV)
14974 {
14975 tempguy.defense[edefARROW] = edCHINK;
14976 tempguy.defense[edefMAGIC] = ed1HKO;
14977 tempguy.defense[edefREFMAGIC] = ed1HKO;
14978 }
14979 }
14980
14981
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion < 17) // December 2009
14982 {
14983 if(tempguy.family==eePROJECTILE)
14984 {
14985 tempguy.misc1 = 0;
14986 }
14987 }
14988
14989
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion < 18) // January 2010
14990 {
14991 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14992 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14993
14994 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14995 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
14996
14997 if(tempguy.family == eeAQUA)
14998 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14999 else if(tempguy.family == eeMANHAN)
15000 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15001 else if(tempguy.family==eePATRA)
15002 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15003 else if(tempguy.family==eeGHOMA)
15004 {
15005 for(int32_t j=0; j<edefLAST; j++)
15006 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15007
15008 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15009
15010 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15011
15012 tempguy.misc1--;
15013 }
15014 else if(tempguy.family == eeGLEEOK)
15015 {
15016 for(int32_t j=0; j<edefLAST; j++)
15017 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15018
15019 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15020 }
15021 else if(tempguy.family == eeARMOS)
15022 {
15023 tempguy.family=eeWALK;
15024 tempguy.hrate = 0;
15025 tempguy.misc10 = tempguy.misc1;
15026 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15027 tempguy.misc9 = e9tARMOS;
15028 }
15029 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15030 {
15031 tempguy.family=eeWALK;
15032 tempguy.hrate = 0;
15033 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15034 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15035 }
15036
15037 // Spawn animation flags
15038 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15039 tempguy.flags |= guy_fadeflicker;
15040 else
15041 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15042 }
15043
15044
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion < 20) // April 2010
15045 {
15046 if(tempguy.family == eeTRAP)
15047 {
15048 tempguy.misc2 = tempguy.misc10;
15049
15050 if(tempguy.misc10>=1)
15051 {
15052 tempguy.misc1++;
15053 }
15054
15055 tempguy.misc10 = 0;
15056 }
15057
15058 // Bomb Blast fix
15059 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15060 tempguy.weapon = ewLitBomb;
15061 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15062 tempguy.weapon = ewLitSBomb;
15063 }
15064
15065
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion < 21) // September 2011
15066 {
15067 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15068 {
15069 if(tempguy.family == eeKEESETRIB)
15070 {
15071 tempguy.family = eeKEESE;
15072 tempguy.misc2 = e2tKEESETRIB;
15073 tempguy.misc1 = 0;
15074 }
15075
15076 tempguy.rate = 2;
15077 tempguy.hrate = 8;
15078 tempguy.homing = 0;
15079 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15080 }
15081 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15082 {
15083 if(tempguy.family == eePEAHAT)
15084 {
15085 tempguy.rate = 4;
15086 tempguy.step = 62;
15087 }
15088 else
15089 tempguy.step = 25;
15090
15091 tempguy.hrate = 8;
15092 tempguy.homing = 0;
15093 }
15094 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15095 {
15096 if(tempguy.family == eeMANHAN)
15097 tempguy.step=50;
15098
15099 tempguy.hrate = 16;
15100 tempguy.homing = 0;
15101 }
15102 else if(tempguy.family == eeGLEEOK)
15103 {
15104 tempguy.rate = 2;
15105 tempguy.homing = 0;
15106 tempguy.hrate = 9;
15107 tempguy.step=89;
15108 }
15109 else if(tempguy.family == eeGHINI)
15110 {
15111 tempguy.rate = 4;
15112 tempguy.hrate = 12;
15113 tempguy.step=62;
15114 tempguy.homing = 0;
15115 }
15116
15117 // Bigdig random rate fix
15118 if(tempguy.family==eeDIG && tempguy.misc10==1)
15119 {
15120 tempguy.rate = 2;
15121 }
15122 }
15123
15124
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(guyversion < 24) // November 2012
15125 {
15126 if(tempguy.family==eeLANM)
15127 tempguy.misc3 = 1;
15128 else if(tempguy.family==eeMOLD)
15129 tempguy.misc2 = 0;
15130 }
15131
15132
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15133 {
15134
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 5554 times.
5632 if(tempguy.family!=eeDIG)
15135 {
15136 5554 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15137 5554 }
15138
15139 5632 }
15140 // does not seem to solve the issue!
15141
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if ( Header->zelda_version <= 0x210 )
15142 {
15143 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15144 if ( tempguy.family == eeDONGO )
15145 {
15146 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15147 }
15148 }
15149
15150
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if(guyversion >= 42)
15151 {
15152
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(guyversion >= 47)
15153 {
15154
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_igetl(&(tempguy.moveflags),f,keepdata))
15155 {
15156 return qe_invalid;
15157 }
15158 1024 }
15159 else
15160 {
15161 byte fl;
15162 if(!p_getc(&fl,f,keepdata))
15163 {
15164 return qe_invalid;
15165 }
15166 tempguy.moveflags = fl;
15167 }
15168 1024 }
15169 else
15170 {
15171
7/8
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4704 times.
✓ Branch 2 taken 134 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 27 times.
✓ Branch 7 taken 677 times.
5632 switch(tempguy.family)
15172 {
15173 //No gravity; floats over pits
15174 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15175 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15176 //Special (bosses, etc)
15177 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15178 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15179 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15180 4704 tempguy.moveflags = FLAG_CAN_PITWALK;
15181 4704 break;
15182 //No gravity, but falls in pits
15183 case eeLEV:
15184 49 tempguy.moveflags = FLAG_CAN_PITFALL;
15185 49 break;
15186 //Bosses that respect pits
15187 case eeDONGO:
15188 36 tempguy.moveflags = FLAG_OBEYS_GRAV;
15189 36 break;
15190 case eeLANM:
15191 27 tempguy.moveflags = 0;
15192 27 break;
15193 //Gravity, floats over pits
15194 case eeWIZZ: case eeWALLM: case eeGHINI:
15195 134 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15196 134 break;
15197 //Gravity and falls in pits
15198 case eeWALK:
15199
4/4
✓ Branch 0 taken 639 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 610 times.
677 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15200 67 break;
15201 [[fallthrough]];
15202 case eeOTHER:
15203 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15204 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15205 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15206 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15207 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15208 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15209 615 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15210 615 }
15211 }
15212
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if(guyversion < 43)
15213 {
15214
2/2
✓ Branch 0 taken 4838 times.
✓ Branch 1 taken 794 times.
5632 switch(tempguy.family)
15215 {
15216 //No gravity; floats over pits
15217 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15218 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15219 //Special (bosses, etc)
15220 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15221 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15222 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15223 case eeWIZZ: case eeWALLM: case eeGHINI:
15224 //Gravity, floats over pits
15225 4838 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15226 4838 break;
15227 }
15228 5632 }
15229
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if (guyversion < 44)
15230 {
15231
2/2
✓ Branch 0 taken 5584 times.
✓ Branch 1 taken 48 times.
5632 if ( tempguy.family == eeGHOMA )
15232 {
15233 48 tempguy.flags |= guy_fadeinstant;
15234 48 }
15235 5632 }
15236
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if (guyversion > 44)
15237 {
15238
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&(tempguy.spr_shadow),f,keepdata))
15239 {
15240 return qe_invalid;
15241 }
15242
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&(tempguy.spr_death),f,keepdata))
15243 {
15244 return qe_invalid;
15245 }
15246
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&(tempguy.spr_spawn),f,keepdata))
15247 {
15248 return qe_invalid;
15249 }
15250 1024 }
15251 else
15252 {
15253
2/2
✓ Branch 0 taken 5610 times.
✓ Branch 1 taken 22 times.
5632 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15254 5632 tempguy.spr_death = iwDeath;
15255 5632 tempguy.spr_spawn = iwSpawn;
15256 }
15257
15258
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 5632 times.
6656 if(guyversion < 46)
15259 {
15260
4/4
✓ Branch 0 taken 677 times.
✓ Branch 1 taken 4955 times.
✓ Branch 2 taken 639 times.
✓ Branch 3 taken 38 times.
5632 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15261 {
15262 38 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15263 38 }
15264 5632 }
15265
15266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
6656 if(keepdata)
15267 {
15268 6656 guysbuf[i] = tempguy;
15269 6656 }
15270 6656 }
15271 13 }
15272
15273 13 return 0;
15274 13 }
15275
15276 void update_guy_1(guydata *tempguy) // November 2009
15277 {
15278 bool doesntcount = false;
15279 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15280
15281 switch(tempguy->family)
15282 {
15283 case 1: //eeWALK
15284 switch(tempguy->misc10)
15285 {
15286 case 0: //Stalfos
15287 if(tempguy->misc1==1) // Fires four projectiles at once
15288 tempguy->misc1=4;
15289
15290 break;
15291
15292 case 1: //Darknut
15293 goto darknuts;
15294 break;
15295 }
15296
15297 tempguy->misc10 = 0;
15298 break;
15299
15300 case 2: //eeSHOOT
15301 tempguy->family = eeWALK;
15302
15303 switch(tempguy->misc10)
15304 {
15305 case 0: //Octorok
15306 if(tempguy->misc1==1||tempguy->misc1==2)
15307 {
15308 tempguy->misc1=e1tFIREOCTO;
15309 tempguy->misc2=e2tFIREOCTO;
15310 }
15311 else tempguy->misc1 = 0;
15312
15313 tempguy->misc6=tempguy->misc4;
15314 tempguy->misc4=tempguy->misc3;
15315 tempguy->misc3=0;
15316 break;
15317
15318 case 1: // Moblin
15319 tempguy->misc1 = 0;
15320 break;
15321
15322 case 2: //Lynel
15323 tempguy->misc6=tempguy->misc1+1;
15324 tempguy->misc1=0;
15325 break;
15326
15327 case 3: //Stalfos 2
15328 if(tempguy->misc1==1) // Fires four projectiles at once
15329 tempguy->misc1=e1t4SHOTS;
15330 else tempguy->misc1 = 0;
15331
15332 break;
15333
15334 case 4: //Darknut 5
15335 darknuts:
15336 tempguy->defense[edefFIRE] = edIGNORE;
15337 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15338 tempguy->defense[edefHOOKSHOT] = 0;
15339 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15340 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15341
15342 if(tempguy->misc1==1)
15343 tempguy->misc1=2;
15344 else if(tempguy->misc1==2)
15345 {
15346 tempguy->misc4=tempguy->misc3;
15347 tempguy->misc3=tempguy->misc2;
15348 tempguy->misc2=e2tSPLIT;
15349 tempguy->misc1 = 0;
15350 }
15351 else tempguy->misc1 = 0;
15352
15353 tempguy->flags |= inv_front;
15354
15355 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15356 tempguy->flags |= guy_bkshield;
15357
15358 break;
15359 }
15360
15361 tempguy->misc10 = 0;
15362 break;
15363
15364 /*
15365 case 9: //eeARMOS
15366 tempguy->family = eeWALK;
15367 break;
15368 */
15369 case 11: //eeGEL
15370 case 33: //eeGELTRIB
15371 if(tempguy->family==33)
15372 {
15373 tempguy->misc4 = 1;
15374
15375 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15376 tempguy->misc3 = tempguy->misc2;
15377
15378 tempguy->misc2 = e2tTRIBBLE;
15379 }
15380 else
15381 {
15382 tempguy->misc4 = 0;
15383 tempguy->misc3 = 0;
15384 tempguy->misc2 = 0;
15385 }
15386
15387 tempguy->family = eeWALK;
15388
15389 if(tempguy->misc1)
15390 {
15391 tempguy->misc1=1;
15392 tempguy->weapon = ewFireTrail;
15393 }
15394
15395 break;
15396
15397 case 34: //eeZOLTRIB
15398 case 12: //eeZOL
15399 tempguy->misc4=tempguy->misc3;
15400 tempguy->misc3=tempguy->misc2;
15401 tempguy->family = eeWALK;
15402 tempguy->misc2=e2tSPLITHIT;
15403
15404 if(tempguy->misc1)
15405 {
15406 tempguy->misc1=1;
15407 tempguy->weapon = ewFireTrail;
15408 }
15409
15410 break;
15411
15412 case 13: //eeROPE
15413 tempguy->family = eeWALK;
15414 tempguy->misc9 = e9tROPE;
15415
15416 if(tempguy->misc1)
15417 {
15418 tempguy->misc4 = tempguy->misc3;
15419 tempguy->misc3 = tempguy->misc2;
15420 tempguy->misc2 = e2tBOMBCHU;
15421 }
15422
15423 tempguy->misc1 = 0;
15424 break;
15425
15426 case 14: //eeGORIYA
15427 tempguy->family = eeWALK;
15428
15429 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15430
15431 break;
15432
15433 case 17: //eeBUBBLE
15434 tempguy->family = eeWALK;
15435 tempguy->misc8 = tempguy->misc2;
15436 tempguy->misc7 = tempguy->misc1 + 1;
15437 tempguy->misc1 = tempguy->misc2 = 0;
15438
15439 //fallthrogh
15440 case eeTRAP:
15441 case eeROCK:
15442 doesntcount = true;
15443 break;
15444
15445 case 35: //eeVIRETRIB
15446 case 18: //eeVIRE
15447 tempguy->family = eeWALK;
15448 tempguy->misc4=tempguy->misc3;
15449 tempguy->misc3=tempguy->misc2;
15450 tempguy->misc2=e2tSPLITHIT;
15451 tempguy->misc9=e9tVIRE;
15452 break;
15453
15454 case 19: //eeLIKE
15455 tempguy->family = eeWALK;
15456 tempguy->misc7 = e7tEATITEMS;
15457 tempguy->misc8=95;
15458 break;
15459
15460 case 20: //eePOLSV
15461 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15462 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15463 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15464 tempguy->defense[edefARROW] = ed1HKO;
15465 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15466 tempguy->family = eeWALK;
15467 tempguy->misc9 = e9tPOLSVOICE;
15468 tempguy->rate = 4;
15469 tempguy->homing = 32;
15470 tempguy->hrate = 10;
15471 tempguy->grumble = 0;
15472 break;
15473
15474 case eeWIZZ:
15475 if(tempguy->misc4)
15476 {
15477 for(int32_t i=0; i < edefLAST; i++)
15478 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15479 }
15480 else
15481 {
15482 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15483 tempguy->defense[edefMAGIC] = edCHINK;
15484 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15485 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15486 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15487 }
15488
15489 break;
15490
15491 case eePEAHAT:
15492 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15493
15494 if(!(tempguy->flags & guy_bhit))
15495 tempguy->defense[edefBRANG] = edSTUNONLY;
15496
15497 break;
15498
15499 case eeLEV:
15500 tempguy->defense[edefSTOMP] = edCHINK;
15501 break;
15502 }
15503
15504 // Old flags
15505 if(tempguy->flags & guy_superman)
15506 {
15507 for(int32_t i = 0; i < edefLAST; i++)
15508 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15509 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15510 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15511 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15512 }
15513
15514 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15515
15516 if(doesntcount)
15517 tempguy->flags |= (guy_doesntcount);
15518 }
15519
15520
15521 8840 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15522 {
15523 byte tempbyte, padding;
15524 int32_t extras, secretcombos;
15525 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->valid),f,true))
15527 {
15528 return qe_invalid;
15529 }
15530
15531
15532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->guy),f,true))
15533 {
15534 return qe_invalid;
15535 }
15536
15537
2/6
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8840 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15538 {
15539 if(!p_getc(&tempbyte,f,true))
15540 {
15541 return qe_invalid;
15542 }
15543
15544 temp_mapscr->str=tempbyte;
15545 }
15546 else
15547 {
15548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_igetw(&(temp_mapscr->str),f,true))
15549 {
15550 return qe_invalid;
15551 }
15552 }
15553
15554
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->room),f,true))
15555 {
15556 return qe_invalid;
15557 }
15558
15559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->item),f,true))
15560 {
15561 return qe_invalid;
15562 }
15563
15564
2/6
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8840 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15565 {
15566 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15567 }
15568 else
15569 {
15570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->hasitem),f,true))
15571 return qe_invalid;
15572 }
15573
15574
1/4
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8840 if((Header->zelda_version < 0x192)||
15575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15576 {
15577 if(!p_getc(&tempbyte,f,true))
15578 {
15579 return qe_invalid;
15580 }
15581 }
15582
15583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f,true))
15584 {
15585 return qe_invalid;
15586 }
15587
15588
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(Header->zelda_version < 0x193)
15589 {
15590 if(!p_getc(&tempbyte,f,true))
15591 {
15592 return qe_invalid;
15593 }
15594 }
15595
15596
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15597 {
15598
2/2
✓ Branch 0 taken 26520 times.
✓ Branch 1 taken 8840 times.
35360 for(int32_t i=1; i<4; i++)
15599 {
15600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26520 times.
26520 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
15601 {
15602 return qe_invalid;
15603 }
15604 26520 }
15605 8840 }
15606 else
15607 {
15608 temp_mapscr->tilewarptype[1]=0;
15609 temp_mapscr->tilewarptype[2]=0;
15610 temp_mapscr->tilewarptype[3]=0;
15611 }
15612
15613
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15614 {
15615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
15616 {
15617 return qe_invalid;
15618 }
15619 8840 }
15620
15621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f,true))
15622 {
15623 return qe_invalid;
15624 }
15625
15626 8840 temp_mapscr->warpreturnx[1]=0;
15627 8840 temp_mapscr->warpreturnx[2]=0;
15628 8840 temp_mapscr->warpreturnx[3]=0;
15629
15630
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15631 {
15632
2/2
✓ Branch 0 taken 26520 times.
✓ Branch 1 taken 8840 times.
35360 for(int32_t i=1; i<4; i++)
15633 {
15634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26520 times.
26520 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
15635 {
15636 return qe_invalid;
15637 }
15638 26520 }
15639 8840 }
15640
15641
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->warpreturny[0]),f,true))
15642 {
15643 return qe_invalid;
15644 }
15645
15646 8840 temp_mapscr->warpreturny[1]=0;
15647 8840 temp_mapscr->warpreturny[2]=0;
15648 8840 temp_mapscr->warpreturny[3]=0;
15649
15650
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15651 {
15652
2/2
✓ Branch 0 taken 26520 times.
✓ Branch 1 taken 8840 times.
35360 for(int32_t i=1; i<4; i++)
15653 {
15654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26520 times.
26520 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
15655 {
15656 return qe_invalid;
15657 }
15658 26520 }
15659
15660
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(version>=18)
15661 {
15662
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
15663 {
15664 return qe_invalid;
15665 }
15666 8840 }
15667 else
15668 {
15669 byte temp;
15670
15671 if(!p_getc(&temp,f,true))
15672 {
15673 return qe_invalid;
15674 }
15675
15676 temp_mapscr->warpreturnc=temp<<8|temp;
15677 }
15678 8840 }
15679
15680
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->stairx),f,true))
15681
15682 {
15683 return qe_invalid;
15684 }
15685
15686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->stairy),f,true))
15687 {
15688 return qe_invalid;
15689 }
15690
15691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->itemx),f,true))
15692 {
15693 return qe_invalid;
15694 }
15695
15696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->itemy),f,true))
15697 {
15698 return qe_invalid;
15699 }
15700
15701
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(version > 15) // February 2009
15702 {
15703
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_igetw(&(temp_mapscr->color),f,true))
15704 {
15705 return qe_invalid;
15706 }
15707 8840 }
15708 else
15709 {
15710 if(!p_getc(& tempbyte,f,true))
15711 {
15712 return qe_invalid;
15713 }
15714
15715 temp_mapscr->color = (word) tempbyte;
15716 }
15717
15718
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
15719 {
15720 return qe_invalid;
15721 }
15722
15723
2/2
✓ Branch 0 taken 35360 times.
✓ Branch 1 taken 8840 times.
44200 for(int32_t k=0; k<4; k++)
15724 {
15725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35360 times.
35360 if(!p_getc(&(temp_mapscr->door[k]),f,true))
15726 {
15727 return qe_invalid;
15728
15729 }
15730 35360 }
15731
15732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(version <= 11)
15733 {
15734 if(!p_getc(&(tempbyte),f,true))
15735 {
15736 return qe_invalid;
15737 }
15738
15739 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15740
15741 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15742 {
15743 for(int32_t i=1; i<4; i++)
15744 {
15745 if(!p_getc(&(tempbyte),f,true))
15746 {
15747 return qe_invalid;
15748 }
15749
15750 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15751 }
15752 }
15753 else
15754 {
15755 temp_mapscr->tilewarpdmap[1]=0;
15756 temp_mapscr->tilewarpdmap[2]=0;
15757 temp_mapscr->tilewarpdmap[3]=0;
15758 }
15759 }
15760 else
15761 {
15762
2/2
✓ Branch 0 taken 35360 times.
✓ Branch 1 taken 8840 times.
44200 for(int32_t i=0; i<4; i++)
15763 {
15764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35360 times.
35360 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
15765 {
15766 return qe_invalid;
15767 }
15768 35360 }
15769 }
15770
15771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f,true))
15772 {
15773 return qe_invalid;
15774 }
15775
15776
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15777 {
15778
2/2
✓ Branch 0 taken 26520 times.
✓ Branch 1 taken 8840 times.
35360 for(int32_t i=1; i<4; i++)
15779 {
15780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26520 times.
26520 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
15781 {
15782 return qe_invalid;
15783 }
15784 26520 }
15785 8840 }
15786 else
15787 {
15788 temp_mapscr->tilewarpscr[1]=0;
15789 temp_mapscr->tilewarpscr[2]=0;
15790 temp_mapscr->tilewarpscr[3]=0;
15791 }
15792
15793
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(version >= 15)
15794 {
15795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
15796 {
15797 return qe_invalid;
15798 }
15799 8840 }
15800 else
15801 {
15802 temp_mapscr->tilewarpoverlayflags=0;
15803 }
15804
15805
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->exitdir),f,true))
15806 {
15807 return qe_invalid;
15808 }
15809
15810
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(Header->zelda_version < 0x193)
15811 {
15812 if(!p_getc(&tempbyte,f,true))
15813 {
15814 return qe_invalid;
15815 }
15816
15817 }
15818
15819
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15820 {
15821 if(!p_getc(&padding,f,true))
15822 {
15823 return qe_invalid;
15824 }
15825 }
15826
15827
2/2
✓ Branch 0 taken 88400 times.
✓ Branch 1 taken 8840 times.
97240 for(int32_t k=0; k<10; k++)
15828 {
15829 /*
15830 if (!temp_mapscr->enemy[k])
15831 {
15832 continue;
15833 }
15834 */
15835
2/6
✓ Branch 0 taken 88400 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 88400 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
88400 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15836 {
15837 if(!p_getc(&tempbyte,f,true))
15838 {
15839 return qe_invalid;
15840 }
15841
15842 temp_mapscr->enemy[k]=tempbyte;
15843 }
15844 else
15845 {
15846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88400 times.
88400 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
15847 {
15848 return qe_invalid;
15849 }
15850 }
15851
15852
2/6
✓ Branch 0 taken 88400 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 88400 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
88400 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15853 {
15854 //using enumerations here is dangerous
15855 //very easy to break old quests -DD
15856 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15857 {
15858 temp_mapscr->enemy[k]+=5;
15859 }
15860 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15861 {
15862 temp_mapscr->enemy[k]+=1;
15863 }
15864 }
15865
15866
1/2
✓ Branch 0 taken 88400 times.
✗ Branch 1 not taken.
88400 if(version < 9)
15867 {
15868 if(temp_mapscr->enemy[k]>0)
15869 {
15870 temp_mapscr->enemy[k]+=10;
15871 }
15872 }
15873 //don't read in any invalid data
15874
1/2
✓ Branch 0 taken 88400 times.
✗ Branch 1 not taken.
88400 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15875 {
15876 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15877 temp_mapscr->enemy[k] = 0;
15878 }
15879 88400 }
15880
15881
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->pattern),f,true))
15882 {
15883 return qe_invalid;
15884 }
15885
15886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f,true))
15887 {
15888 return qe_invalid;
15889 }
15890
15891
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15892 {
15893
2/2
✓ Branch 0 taken 26520 times.
✓ Branch 1 taken 8840 times.
35360 for(int32_t i=1; i<4; i++)
15894 {
15895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26520 times.
26520 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
15896 {
15897 return qe_invalid;
15898 }
15899 26520 }
15900 8840 }
15901 else
15902 {
15903 temp_mapscr->sidewarptype[1]=0;
15904 temp_mapscr->sidewarptype[2]=0;
15905 temp_mapscr->sidewarptype[3]=0;
15906 }
15907
15908
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(version >= 15)
15909 {
15910
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
15911 {
15912 return qe_invalid;
15913 }
15914 8840 }
15915 else
15916 {
15917 temp_mapscr->sidewarpoverlayflags=0;
15918 }
15919
15920
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
15921 {
15922 return qe_invalid;
15923 }
15924
15925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
15926 {
15927 return qe_invalid;
15928 }
15929
15930
2/2
✓ Branch 0 taken 35360 times.
✓ Branch 1 taken 8840 times.
44200 for(int32_t k=0; k<4; k++)
15931 {
15932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35360 times.
35360 if(!p_getc(&(temp_mapscr->path[k]),f,true))
15933 {
15934 return qe_invalid;
15935 }
15936 35360 }
15937
15938
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f,true))
15939 {
15940 return qe_invalid;
15941 }
15942
15943
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15944 {
15945
2/2
✓ Branch 0 taken 8840 times.
✓ Branch 1 taken 26520 times.
35360 for(int32_t i=1; i<4; i++)
15946 {
15947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26520 times.
26520 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
15948 {
15949 return qe_invalid;
15950 }
15951 26520 }
15952 8840 }
15953 else
15954 {
15955 temp_mapscr->sidewarpscr[1]=0;
15956 temp_mapscr->sidewarpscr[2]=0;
15957 temp_mapscr->sidewarpscr[3]=0;
15958 }
15959
15960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(version <= 11)
15961 {
15962 if(!p_getc(&(tempbyte),f,true))
15963 {
15964 return qe_invalid;
15965 }
15966
15967 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15968
15969 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15970 {
15971 for(int32_t i=1; i<4; i++)
15972 {
15973 if(!p_getc(&(tempbyte),f,true))
15974 {
15975 return qe_invalid;
15976 }
15977
15978 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15979 }
15980 }
15981 else
15982 {
15983 temp_mapscr->sidewarpdmap[1]=0;
15984 temp_mapscr->sidewarpdmap[2]=0;
15985 temp_mapscr->sidewarpdmap[3]=0;
15986 }
15987 }
15988 else
15989 {
15990
2/2
✓ Branch 0 taken 35360 times.
✓ Branch 1 taken 8840 times.
44200 for(int32_t i=0; i<4; i++)
15991 {
15992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35360 times.
35360 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
15993 {
15994 return qe_invalid;
15995 }
15996 35360 }
15997 }
15998
15999
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16000 {
16001
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
16002 {
16003 return qe_invalid;
16004 }
16005 8840 }
16006 else temp_mapscr->sidewarpindex = 0;
16007
16008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
16009 {
16010 return qe_invalid;
16011 }
16012
16013
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(Header->zelda_version < 0x193)
16014 {
16015 if(!p_getc(&(temp_mapscr->old_cpage),f,true))
16016 {
16017 return qe_invalid;
16018 }
16019 }
16020
16021
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->undercset),f,true)) //recalculated for older quests
16022 {
16023 return qe_invalid;
16024 }
16025
16026
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16027 {
16028 return qe_invalid;
16029 }
16030
16031
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->flags),f,true))
16032 {
16033 return qe_invalid;
16034 }
16035
16036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->flags2),f,true))
16037 {
16038 return qe_invalid;
16039 }
16040
16041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->flags3),f,true))
16042 {
16043 return qe_invalid;
16044 }
16045
16046
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16047 //if (version>2)
16048 {
16049
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->flags4),f,true))
16050 {
16051 return qe_invalid;
16052 }
16053 8840 }
16054
16055
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16056 {
16057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->flags5),f,true))
16058 {
16059 return qe_invalid;
16060 }
16061
16062
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_igetw(&(temp_mapscr->noreset),f,true))
16063 {
16064 return qe_invalid;
16065 }
16066
16067
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
16068 {
16069 return qe_invalid;
16070 }
16071
16072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(temp_mapscr->flags5&32)
16073 {
16074 temp_mapscr->flags5 &= ~32;
16075 temp_mapscr->noreset |= 48;
16076 }
16077
16078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(version<8)
16079 {
16080 if(temp_mapscr->noreset&1)
16081 {
16082 temp_mapscr->noreset|=8192;
16083 }
16084
16085 if(temp_mapscr->nocarry&1)
16086 {
16087 temp_mapscr->nocarry|=8192;
16088 temp_mapscr->nocarry&=~1;
16089 }
16090 }
16091 8840 }
16092 else
16093 {
16094 temp_mapscr->flags5 = 0;
16095 temp_mapscr->noreset = 0;
16096 temp_mapscr->nocarry = 0;
16097 }
16098
16099
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16100 {
16101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->flags6),f,true))
16102 {
16103 return qe_invalid;
16104 }
16105 8840 }
16106
16107
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(version>5)
16108 {
16109
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->flags7),f,true))
16110 {
16111 return qe_invalid;
16112 }
16113
16114
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->flags8),f,true))
16115 {
16116 return qe_invalid;
16117 }
16118
16119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->flags9),f,true))
16120 {
16121 return qe_invalid;
16122 }
16123
16124
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->flags10),f,true))
16125 {
16126 return qe_invalid;
16127 }
16128
16129
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->csensitive),f,true))
16130 {
16131 return qe_invalid;
16132 }
16133 8840 }
16134 else
16135 {
16136 temp_mapscr->csensitive=1;
16137 }
16138
16139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(version<14) // August 2007: screen SFX added
16140 {
16141 if(temp_mapscr->flags&8) //fROAR
16142 {
16143 temp_mapscr->bosssfx=
16144 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16145 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16146 WAV_ROAR;
16147 }
16148
16149 if(temp_mapscr->flags&128) //fSEA
16150 {
16151 temp_mapscr->oceansfx=WAV_SEA;
16152 }
16153
16154 if(!(temp_mapscr->flags3&64)) //fNOSECRETSOUND
16155 {
16156 temp_mapscr->secretsfx=WAV_SECRET;
16157 }
16158
16159 temp_mapscr->flags3 &= ~66; //64|2
16160 temp_mapscr->flags2 &= ~32;
16161 temp_mapscr->flags &= ~136; // 128|8
16162 }
16163 else
16164 {
16165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
16166 {
16167 return qe_invalid;
16168 }
16169
16170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
16171 {
16172 return qe_invalid;
16173 }
16174
16175
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
16176 {
16177 return qe_invalid;
16178 }
16179 }
16180
16181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(version<15) // October 2007: another SFX
16182 {
16183 temp_mapscr->holdupsfx=WAV_PICKUP;
16184 }
16185 else
16186 {
16187
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
16188 {
16189 return qe_invalid;
16190 }
16191 }
16192
16193
16194
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16195 {
16196
2/2
✓ Branch 0 taken 53040 times.
✓ Branch 1 taken 8840 times.
61880 for(int32_t k=0; k<6; k++)
16197 {
16198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53040 times.
53040 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
16199 {
16200 return qe_invalid;
16201 }
16202 53040 }
16203
16204
2/2
✓ Branch 0 taken 8840 times.
✓ Branch 1 taken 53040 times.
61880 for(int32_t k=0; k<6; k++)
16205 {
16206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53040 times.
53040 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
16207 {
16208 return qe_invalid;
16209 }
16210 53040 }
16211 8840 }
16212 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16213 {
16214 if(!p_getc(&(temp_mapscr->layermap[2]),f,true))
16215 {
16216 return qe_invalid;
16217 }
16218
16219 if(!p_getc(&(temp_mapscr->layerscreen[2]),f,true))
16220 {
16221 return qe_invalid;
16222 }
16223
16224 if(!p_getc(&(temp_mapscr->layermap[4]),f,true))
16225 {
16226 return qe_invalid;
16227 }
16228
16229 if(!p_getc(&(temp_mapscr->layerscreen[4]),f,true))
16230
16231 {
16232 return qe_invalid;
16233 }
16234 }
16235
16236
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8840 if((Header->zelda_version == 0x192)&&(Header->build>149))
16237 {
16238 for(int32_t k=0; k<6; k++)
16239 {
16240 if(!p_getc(&tempbyte,f,true)) //layerxsize
16241 {
16242 return qe_invalid;
16243 }
16244 }
16245
16246 for(int32_t k=0; k<6; k++)
16247 {
16248 if(!p_getc(&tempbyte,f,true)) //layerxspeed
16249 {
16250 return qe_invalid;
16251 }
16252 }
16253
16254 for(int32_t k=0; k<6; k++)
16255 {
16256 if(!p_getc(&tempbyte,f,true)) //layerxdelay
16257 {
16258 return qe_invalid;
16259 }
16260 }
16261
16262 for(int32_t k=0; k<6; k++)
16263 {
16264 if(!p_getc(&tempbyte,f,true)) //layerysize
16265 {
16266 return qe_invalid;
16267 }
16268 }
16269
16270 for(int32_t k=0; k<6; k++)
16271 {
16272 if(!p_getc(&tempbyte,f,true)) //layeryspeed
16273 {
16274 return qe_invalid;
16275 }
16276 }
16277
16278 for(int32_t k=0; k<6; k++)
16279 {
16280 if(!p_getc(&tempbyte,f,true)) //layerydelay
16281 {
16282 return qe_invalid;
16283 }
16284 }
16285 }
16286
16287
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16288 {
16289
2/2
✓ Branch 0 taken 53040 times.
✓ Branch 1 taken 8840 times.
61880 for(int32_t k=0; k<6; k++)
16290 {
16291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53040 times.
53040 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
16292 {
16293 return qe_invalid;
16294 }
16295 53040 }
16296 8840 }
16297
16298
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16299 {
16300
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8840 if((Header->zelda_version == 0x192)&&(Header->build>153))
16301 {
16302 if(!p_getc(&padding,f,true))
16303 {
16304 return qe_invalid;
16305 }
16306 }
16307
16308
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
16309 {
16310 return qe_invalid;
16311 }
16312 8840 }
16313
16314
2/6
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8840 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16315 {
16316 extras=15;
16317 }
16318
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8840 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16319 {
16320 extras=11;
16321 }
16322
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8840 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16323 {
16324 extras=32;
16325 }
16326
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8840 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16327 {
16328 extras=64;
16329 }
16330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 else if(Header->zelda_version < 0x193)
16331 {
16332 extras=62;
16333 }
16334 else
16335
16336 {
16337 8840 extras=0;
16338 }
16339
16340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 for(int32_t k=0; k<extras; k++)
16341 {
16342 if(!p_getc(&tempbyte,f,true)) //extra[k]
16343 {
16344 return qe_invalid;
16345 }
16346 }
16347
16348
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16349 //if (version>3)
16350 {
16351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_getc(&(temp_mapscr->nextmap),f,true))
16352 {
16353 return qe_invalid;
16354 }
16355
16356
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->nextscr),f,true))
16357 {
16358 return qe_invalid;
16359 }
16360 8840 }
16361 else
16362 {
16363 temp_mapscr->nextmap=0;
16364 temp_mapscr->nextscr=0;
16365 }
16366
16367
2/6
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8840 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16368 {
16369 secretcombos=20;
16370 }
16371
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8840 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16372 {
16373 secretcombos=256;
16374 }
16375 else
16376 {
16377 8840 secretcombos=128;
16378 }
16379
16380
2/6
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8840 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16381 {
16382 for(int32_t k=0; k<secretcombos; k++)
16383 {
16384 if(!p_getc(&tempbyte,f,true))
16385 {
16386 return qe_invalid;
16387 }
16388
16389 if(k<128)
16390 {
16391 temp_mapscr->secretcombo[k]=tempbyte;
16392 }
16393 }
16394 }
16395 else
16396 {
16397
2/2
✓ Branch 0 taken 1131520 times.
✓ Branch 1 taken 8840 times.
1140360 for(int32_t k=0; k<128; k++)
16398 {
16399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1131520 times.
1131520 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
16400 {
16401 return qe_invalid;
16402 }
16403
16404 1131520 }
16405 }
16406
16407
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16408 {
16409
2/2
✓ Branch 0 taken 1131520 times.
✓ Branch 1 taken 8840 times.
1140360 for(int32_t k=0; k<128; k++)
16410 {
16411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1131520 times.
1131520 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
16412 {
16413 return qe_invalid;
16414 }
16415 1131520 }
16416
16417
2/2
✓ Branch 0 taken 1131520 times.
✓ Branch 1 taken 8840 times.
1140360 for(int32_t k=0; k<128; k++)
16418 {
16419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1131520 times.
1131520 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
16420 {
16421 return qe_invalid;
16422 }
16423 1131520 }
16424 8840 }
16425
16426
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16427 {
16428 if(!p_getc(&padding,f,true))
16429 {
16430 return qe_invalid;
16431 }
16432 }
16433
16434 8840 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16435
16436
2/2
✓ Branch 0 taken 1555840 times.
✓ Branch 1 taken 8840 times.
1564680 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16437 {
16438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1555840 times.
1555840 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
16439 {
16440 return qe_invalid;
16441 }
16442 1555840 }
16443
16444
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16445 {
16446 if(!p_getc(&padding,f,true))
16447 {
16448 return qe_invalid;
16449 }
16450
16451 if(!p_getc(&padding,f,true))
16452 {
16453 return qe_invalid;
16454 }
16455 }
16456
16457
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16458 {
16459
2/2
✓ Branch 0 taken 1555840 times.
✓ Branch 1 taken 8840 times.
1564680 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16460 {
16461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1555840 times.
1555840 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
16462 {
16463 return qe_invalid;
16464 }
16465
16466
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1555840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1555840 if((Header->zelda_version == 0x192)&&(Header->build<24))
16467 {
16468 if(!p_getc(&tempbyte,f,true))
16469 {
16470 return qe_invalid;
16471 }
16472
16473 if(!p_getc(&tempbyte,f,true))
16474 {
16475 return qe_invalid;
16476 }
16477
16478 if(!p_getc(&tempbyte,f,true))
16479 {
16480 return qe_invalid;
16481 }
16482 }
16483 1555840 }
16484 8840 }
16485
16486
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16487 {
16488
2/2
✓ Branch 0 taken 8840 times.
✓ Branch 1 taken 1555840 times.
1564680 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16489 {
16490
16491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1555840 times.
1555840 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
16492 {
16493 return qe_invalid;
16494 }
16495 1555840 }
16496 8840 }
16497
16498
2/6
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8840 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16499 {
16500 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16501 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16502 }
16503
16504
2/6
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8840 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16505 {
16506 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16507 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16508 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16509 temp_mapscr->secretcombo[sDINSFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16510 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16511 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16512 }
16513
16514
2/6
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8840 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8840 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16515 {
16516 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16517 {
16518 if((Header->zelda_version == 0x192)&&(Header->build>149))
16519 {
16520 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16521 {
16522 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16523 }
16524 }
16525 else
16526 {
16527 if((Header->zelda_version < 0x192)||
16528 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16529 {
16530 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16531 }
16532
16533 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16534 }
16535
16536 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16537 }
16538 }
16539
16540 /*if(version>12)
16541 {
16542 if(!p_getc(&(temp_mapscr->scrWidth),f,true))
16543 {
16544 return qe_invalid;
16545 }
16546 if(!p_getc(&(temp_mapscr->scrHeight),f,true))
16547 {
16548 return qe_invalid;
16549 }
16550 }*/
16551
16552
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(version>4)
16553 {
16554
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
16555 {
16556 return qe_invalid;
16557 }
16558 8840 }
16559 else
16560 {
16561 temp_mapscr->screen_midi = -1;
16562 }
16563
16564
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(version>=17)
16565 {
16566
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
16567 {
16568 return qe_invalid;
16569 }
16570 8840 }
16571 else
16572 {
16573 temp_mapscr->lens_layer = llNORMAL;
16574 }
16575
16576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(version>6)
16577 {
16578 dword bits;
16579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if(!p_igetl(&bits,f,true))
16580 {
16581 return qe_invalid;
16582 }
16583
16584 int32_t m;
16585 float tempfloat;
16586 word tempw;
16587
16588
2/2
✓ Branch 0 taken 8840 times.
✓ Branch 1 taken 282880 times.
291720 for(m=0; m<32; m++)
16589 {
16590 282880 ffcdata& tempffc = temp_mapscr->ffcs[m];
16591 282880 tempffc.clear();
16592
2/2
✓ Branch 0 taken 282467 times.
✓ Branch 1 taken 413 times.
282880 if((bits>>m)&1)
16593 {
16594
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if(!p_igetw(&tempw,f,true))
16595 {
16596 return qe_invalid;
16597 }
16598 413 tempffc.setData(tempw);
16599
16600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_getc(&(tempffc.cset),f,true))
16601 {
16602 return qe_invalid;
16603 }
16604
16605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_igetw(&(tempffc.delay),f,true))
16606 {
16607 return qe_invalid;
16608 }
16609
16610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(version < 9)
16611 {
16612 if(!p_igetf(&tempfloat,f,true))
16613 {
16614 return qe_invalid;
16615 }
16616
16617 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16618
16619 if(!p_igetf(&tempfloat,f,true))
16620 {
16621 return qe_invalid;
16622 }
16623
16624 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16625
16626 if(!p_igetf(&tempfloat,f,true))
16627 {
16628 return qe_invalid;
16629 }
16630
16631 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16632
16633 if(!p_igetf(&tempfloat,f,true))
16634 {
16635 return qe_invalid;
16636 }
16637
16638 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16639
16640 if(!p_igetf(&tempfloat,f,true))
16641 {
16642 return qe_invalid;
16643 }
16644
16645 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16646
16647 if(!p_igetf(&tempfloat,f,true))
16648 {
16649 return qe_invalid;
16650 }
16651
16652 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16653 }
16654 else
16655 {
16656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_igetzf(&(tempffc.x),f,true))
16657 {
16658 return qe_invalid;
16659 }
16660
16661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_igetzf(&(tempffc.y),f,true))
16662 {
16663 return qe_invalid;
16664 }
16665
16666
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if(!p_igetzf(&(tempffc.vx),f,true))
16667 {
16668 return qe_invalid;
16669 }
16670
16671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_igetzf(&(tempffc.vy),f,true))
16672 {
16673 return qe_invalid;
16674 }
16675
16676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_igetzf(&(tempffc.ax),f,true))
16677 {
16678 return qe_invalid;
16679 }
16680
16681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_igetzf(&(tempffc.ay),f,true))
16682 {
16683 return qe_invalid;
16684 }
16685 }
16686
16687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_getc(&(tempffc.link),f,true))
16688 {
16689 return qe_invalid;
16690 }
16691
16692
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if(version>7)
16693 {
16694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_getc(&tempbyte,f,true))
16695 {
16696 return qe_invalid;
16697 }
16698
16699 413 tempffc.hxsz = (tempbyte&0x3F)+1;
16700 413 tempffc.txsz = (tempbyte>>6)+1;
16701
16702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_getc(&tempbyte,f,true))
16703 {
16704 return qe_invalid;
16705 }
16706
16707 413 tempffc.hysz = (tempbyte&0x3F)+1;
16708 413 tempffc.tysz = (tempbyte>>6)+1;
16709
16710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_igetl(&(tempffc.flags),f,true))
16711 {
16712 return qe_invalid;
16713 }
16714 413 }
16715 else
16716 {
16717 tempffc.hxsz=16;
16718 tempffc.hysz=16;
16719 tempffc.txsz=1;
16720 tempffc.tysz=1;
16721 tempffc.flags=0;
16722 }
16723
16724 413 tempffc.updateSolid();
16725
16726
16727
3/6
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 413 times.
413 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16728 {
16729 tempffc.flags|=ffIGNOREHOLDUP;
16730 }
16731
16732
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if(version>9)
16733 {
16734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_igetw(&(tempffc.script),f,true))
16735 {
16736 return qe_invalid;
16737 }
16738 413 }
16739 else
16740 {
16741 tempffc.script=0;
16742 }
16743
16744
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if(version>10)
16745 {
16746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_igetl(&(tempffc.initd[0]),f,true))
16747 {
16748 return qe_invalid;
16749 }
16750
16751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_igetl(&(tempffc.initd[1]),f,true))
16752 {
16753 return qe_invalid;
16754 }
16755
16756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_igetl(&(tempffc.initd[2]),f,true))
16757 {
16758 return qe_invalid;
16759 }
16760
16761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_igetl(&(tempffc.initd[3]),f,true))
16762 {
16763 return qe_invalid;
16764 }
16765
16766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_igetl(&(tempffc.initd[4]),f,true))
16767 {
16768 return qe_invalid;
16769 }
16770
16771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_igetl(&(tempffc.initd[5]),f,true))
16772 {
16773 return qe_invalid;
16774 }
16775
16776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_igetl(&(tempffc.initd[6]),f,true))
16777 {
16778 return qe_invalid;
16779 }
16780
16781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_igetl(&(tempffc.initd[7]),f,true))
16782 {
16783 return qe_invalid;
16784 }
16785
16786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_getc(&(tempbyte),f,true))
16787 {
16788 return qe_invalid;
16789 }
16790
16791 413 tempffc.inita[0]=tempbyte*10000;
16792
16793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if(!p_getc(&(tempbyte),f,true))
16794 {
16795 return qe_invalid;
16796 }
16797
16798 413 tempffc.inita[1]=tempbyte*10000;
16799 413 }
16800 else
16801 {
16802 tempffc.inita[0] = 10000;
16803 tempffc.inita[1] = 10000;
16804 }
16805
16806 413 tempffc.initialized = false;
16807
16808
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if(version <= 11)
16809 {
16810 fixffcs=true;
16811 }
16812 413 }
16813 282880 }
16814
16815 8840 }
16816
16817 //add in the new whistle flags
16818
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(version<13)
16819 {
16820 if(temp_mapscr->flags & fWHISTLE)
16821 {
16822 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16823 }
16824 }
16825
16826 // for(int32_t m=0; m<32; m++)
16827 // {
16828 // // ffcScriptData used to be part of mapscr, and this was handled just above
16829 // ffcScriptData[m].a[0] = 10000;
16830 // ffcScriptData[m].a[1] = 10000;
16831 // }
16832
16833 //2.55 starts here
16834
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8840 if ( version >= 19 && Header->zelda_version > 0x253 )
16835 {
16836 for ( int32_t q = 0; q < 10; q++ )
16837 {
16838 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
16839 {
16840 return qe_invalid;
16841 }
16842 }
16843 for ( int32_t q = 0; q < 10; q++ )
16844 {
16845 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
16846 {
16847 return qe_invalid;
16848 }
16849 }
16850 for ( int32_t q = 0; q < 10; q++ )
16851 {
16852 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
16853 {
16854 return qe_invalid;
16855 }
16856 }
16857 for ( int32_t q = 0; q < 10; q++ )
16858 {
16859 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
16860 {
16861 return qe_invalid;
16862 }
16863 }
16864 }
16865
2/4
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8840 times.
8840 if ( version < 19 && Header->zelda_version > 0x253 )
16866 {
16867 for ( int32_t q = 0; q < 10; q++ )
16868 {
16869 temp_mapscr->npcstrings[q] = 0;
16870 temp_mapscr->new_items[q] = 0;
16871 temp_mapscr->new_item_x[q] = 0;
16872 temp_mapscr->new_item_y[q] = 0;
16873 }
16874 }
16875
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8840 if ( version >= 20 && Header->zelda_version > 0x253 )
16876 {
16877 if(!p_igetw(&(temp_mapscr->script),f,true))
16878 {
16879 return qe_invalid;
16880 }
16881 for ( int32_t q = 0; q < 8; q++)
16882 {
16883 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
16884 {
16885 return qe_invalid;
16886 }
16887 }
16888 }
16889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
8840 if ( version < 20 )
16890 {
16891 8840 temp_mapscr->script = 0;
16892
2/2
✓ Branch 0 taken 70720 times.
✓ Branch 1 taken 8840 times.
79560 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16893 8840 }
16894
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8840 if ( version >= 21 && Header->zelda_version > 0x253 )
16895 {
16896 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
16897 {
16898 return qe_invalid;
16899 }
16900 }
16901
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if ( version < 21 )
16902 {
16903 8840 temp_mapscr->preloadscript = 0;
16904 8840 }
16905 //all builds with version > 20 need this. -Z
16906 8840 temp_mapscr->ffcswaitdraw = 0;
16907
16908
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8840 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16909 {
16910 if(!p_getc(&(temp_mapscr->hidelayers ),f,true))
16911 {
16912 return qe_invalid;
16913 }
16914 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f,true))
16915 {
16916 return qe_invalid;
16917 }
16918 }
16919
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if ( version < 22 )
16920 {
16921 8840 temp_mapscr->hidelayers = 0;
16922 8840 temp_mapscr->hidescriptlayers = 0;
16923 8840 }
16924
16925 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16926 //May be any version before 2.11. -Z
16927 /* --not the roar, the HIT SFX
16928 if ( Header->zelda_version <= 0x210 )
16929 {
16930 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16931 {
16932 temp_mapscr->bosssfx = WAV_ROAR;
16933 }
16934 }
16935 */
16936
16937 8840 return 0;
16938 8840 }
16939 9384 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
16940 {
16941
2/2
✓ Branch 0 taken 8840 times.
✓ Branch 1 taken 544 times.
9384 if(version < 23)
16942 {
16943 8840 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
16944
1/2
✓ Branch 0 taken 8840 times.
✗ Branch 1 not taken.
8840 if(ret) return ret;
16945 8840 temp_mapscr->update_ffc_count(31);
16946 8840 }
16947 else
16948 {
16949
1/2
✓ Branch 0 taken 544 times.
✗ Branch 1 not taken.
544 if(!p_getc(&(temp_mapscr->valid),f,true))
16950 return qe_invalid;
16951
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 508 times.
544 if(!(temp_mapscr->valid & mVALID))
16952 508 return 0; //Empty screen
16953 uint32_t scr_has_flags;
16954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!p_igetl(&scr_has_flags,f,true))
16955 return qe_invalid;
16956
16957
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(scr_has_flags & SCRHAS_ROOMDATA)
16958 {
16959 if(!p_getc(&(temp_mapscr->guy),f,true))
16960 return qe_invalid;
16961 if(!p_igetw(&(temp_mapscr->str),f,true))
16962 return qe_invalid;
16963 if(!p_getc(&(temp_mapscr->room),f,true))
16964 return qe_invalid;
16965 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16966 return qe_invalid;
16967 }
16968
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(scr_has_flags & SCRHAS_ITEM)
16969 {
16970
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&(temp_mapscr->item),f,true))
16971 return qe_invalid;
16972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!p_getc(&(temp_mapscr->hasitem),f,true))
16973 return qe_invalid;
16974
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&(temp_mapscr->itemx),f,true))
16975 return qe_invalid;
16976
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&(temp_mapscr->itemy),f,true))
16977 return qe_invalid;
16978 1 }
16979
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 5 times.
36 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16980 {
16981
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
16982 return qe_invalid;
16983 5 }
16984
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(scr_has_flags & SCRHAS_TWARP)
16985 {
16986
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
16987 {
16988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
16989 return qe_invalid;
16990 4 }
16991
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
16992 {
16993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
16994 return qe_invalid;
16995 4 }
16996
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<4; i++)
16997 {
16998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
16999 return qe_invalid;
17000 4 }
17001
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
17002 return qe_invalid;
17003 1 }
17004
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4 times.
36 if(scr_has_flags & SCRHAS_SWARP)
17005 {
17006
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<4; i++)
17007 {
17008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
17009 return qe_invalid;
17010 16 }
17011
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<4; i++)
17012 {
17013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
17014 return qe_invalid;
17015 16 }
17016
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<4; i++)
17017 {
17018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
17019 return qe_invalid;
17020 16 }
17021
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
17022 return qe_invalid;
17023
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
17024 return qe_invalid;
17025 4 }
17026
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 8 times.
36 if(scr_has_flags & SCRHAS_WARPRET)
17027 {
17028
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 8 times.
40 for(int32_t i=0; i<4; i++)
17029 {
17030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
17031 return qe_invalid;
17032 32 }
17033
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 8 times.
40 for(int32_t i=0; i<4; i++)
17034 {
17035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
17036 return qe_invalid;
17037 32 }
17038
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
17039 return qe_invalid;
17040
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
17041 return qe_invalid;
17042 8 }
17043
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 29 times.
36 if(scr_has_flags & SCRHAS_LAYERS)
17044 {
17045
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 7 times.
49 for(int32_t k=0; k<6; k++)
17046 {
17047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
17048 return qe_invalid;
17049 42 }
17050
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 7 times.
49 for(int32_t k=0; k<6; k++)
17051 {
17052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
17053 return qe_invalid;
17054 42 }
17055
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 7 times.
49 for(int32_t k=0; k<6; k++)
17056 {
17057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
17058 return qe_invalid;
17059 42 }
17060
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&(temp_mapscr->hidelayers),f,true))
17061 return qe_invalid;
17062
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&(temp_mapscr->hidescriptlayers),f,true))
17063 return qe_invalid;
17064 7 }
17065 else
17066 {
17067
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 29 times.
203 for(int32_t k=0; k<6; k++)
17068 {
17069 174 temp_mapscr->layeropacity[k] = 255;
17070 174 }
17071 }
17072
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(scr_has_flags & SCRHAS_MAZE)
17073 {
17074 for(int32_t k=0; k<4; k++)
17075 {
17076 if(!p_getc(&(temp_mapscr->path[k]),f,true))
17077 return qe_invalid;
17078 }
17079 if(!p_getc(&(temp_mapscr->exitdir),f,true))
17080 return qe_invalid;
17081 }
17082
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 8 times.
36 if(scr_has_flags & SCRHAS_D_S_U)
17083 {
17084
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
17085 return qe_invalid;
17086
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 8 times.
40 for(int32_t k=0; k<4; k++)
17087 {
17088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&(temp_mapscr->door[k]),f,true))
17089 return qe_invalid;
17090 32 }
17091
17092
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&(temp_mapscr->stairx),f,true))
17093 return qe_invalid;
17094
17095
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&(temp_mapscr->stairy),f,true))
17096 return qe_invalid;
17097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
17098 return qe_invalid;
17099
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&(temp_mapscr->undercset),f,true))
17100 return qe_invalid;
17101 8 }
17102
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 13 times.
36 if(scr_has_flags & SCRHAS_FLAGS)
17103 {
17104
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&(temp_mapscr->flags),f,true))
17105 return qe_invalid;
17106
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&(temp_mapscr->flags2),f,true))
17107 return qe_invalid;
17108
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&(temp_mapscr->flags3),f,true))
17109 return qe_invalid;
17110
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&(temp_mapscr->flags4),f,true))
17111 return qe_invalid;
17112
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&(temp_mapscr->flags5),f,true))
17113 return qe_invalid;
17114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!p_getc(&(temp_mapscr->flags6),f,true))
17115 return qe_invalid;
17116
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&(temp_mapscr->flags7),f,true))
17117 return qe_invalid;
17118
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&(temp_mapscr->flags8),f,true))
17119 return qe_invalid;
17120
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&(temp_mapscr->flags9),f,true))
17121 return qe_invalid;
17122
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_getc(&(temp_mapscr->flags10),f,true))
17123 return qe_invalid;
17124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
17125 return qe_invalid;
17126 13 }
17127
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 3 times.
36 if(scr_has_flags & SCRHAS_ENEMY)
17128 {
17129
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 3 times.
33 for(int32_t k=0; k<10; k++)
17130 {
17131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
17132 return qe_invalid;
17133
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17134 temp_mapscr->enemy[k] = 0;
17135 30 }
17136
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!p_getc(&(temp_mapscr->pattern),f,true))
17137 return qe_invalid;
17138 3 }
17139
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(scr_has_flags & SCRHAS_CARRY)
17140 {
17141 if(!p_igetw(&(temp_mapscr->noreset),f,true))
17142 return qe_invalid;
17143 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
17144 return qe_invalid;
17145 if(!p_getc(&(temp_mapscr->nextmap),f,true))
17146 return qe_invalid;
17147 if(!p_getc(&(temp_mapscr->nextscr),f,true))
17148 return qe_invalid;
17149 }
17150
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(scr_has_flags & SCRHAS_SCRIPT)
17151 {
17152 if(!p_igetw(&(temp_mapscr->script),f,true))
17153 return qe_invalid;
17154 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17155 return qe_invalid;
17156 for ( int32_t q = 0; q < 8; q++ )
17157 {
17158 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17159 return qe_invalid;
17160 }
17161 }
17162
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(scr_has_flags & SCRHAS_UNUSED)
17163 {
17164 for ( int32_t q = 0; q < 10; q++ )
17165 {
17166 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17167 return qe_invalid;
17168 }
17169 for ( int32_t q = 0; q < 10; q++ )
17170 {
17171 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17172 return qe_invalid;
17173 }
17174 for ( int32_t q = 0; q < 10; q++ )
17175 {
17176 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17177 return qe_invalid;
17178 }
17179 for ( int32_t q = 0; q < 10; q++ )
17180 {
17181 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17182 return qe_invalid;
17183 }
17184 }
17185
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 8 times.
36 if(scr_has_flags & SCRHAS_SECRETS)
17186 {
17187
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 8 times.
1032 for(int32_t k=0; k<128; k++)
17188 {
17189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
17190 return qe_invalid;
17191 1024 }
17192
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 8 times.
1032 for(int32_t k=0; k<128; k++)
17193 {
17194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
17195 return qe_invalid;
17196 1024 }
17197
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 8 times.
1032 for(int32_t k=0; k<128; k++)
17198 {
17199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
17200 return qe_invalid;
17201 1024 }
17202 8 }
17203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(scr_has_flags & SCRHAS_COMBOFLAG)
17204 {
17205
2/2
✓ Branch 0 taken 6336 times.
✓ Branch 1 taken 36 times.
6372 for(int32_t k=0; k<176; ++k)
17206 {
17207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6336 times.
6336 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
17208 return qe_invalid;
17209 6336 }
17210
2/2
✓ Branch 0 taken 6336 times.
✓ Branch 1 taken 36 times.
6372 for(int32_t k=0; k<176; ++k)
17211 {
17212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6336 times.
6336 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
17213 return qe_invalid;
17214 6336 }
17215
2/2
✓ Branch 0 taken 6336 times.
✓ Branch 1 taken 36 times.
6372 for(int32_t k=0; k<176; ++k)
17216 {
17217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6336 times.
6336 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
17218 return qe_invalid;
17219 6336 }
17220 36 }
17221
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(scr_has_flags & SCRHAS_MISC)
17222 {
17223
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&(temp_mapscr->color),f,true))
17224 return qe_invalid;
17225
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&(temp_mapscr->csensitive),f,true))
17226 return qe_invalid;
17227
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
17228 return qe_invalid;
17229
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
17230 return qe_invalid;
17231
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
17232 return qe_invalid;
17233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
17234 return qe_invalid;
17235
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
17236 return qe_invalid;
17237
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
17238 return qe_invalid;
17239
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
17240 return qe_invalid;
17241 36 }
17242 else
17243 {
17244 temp_mapscr->screen_midi = -1;
17245 temp_mapscr->csensitive = 1;
17246 }
17247 //FFC
17248 36 bool old_ff = version < 25;
17249 36 dword bits = 0;
17250 36 word numffc = 32;
17251
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 25 times.
36 if(old_ff)
17252 {
17253
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetl(&bits,f,true))
17254 return qe_invalid;
17255 11 }
17256 else
17257 {
17258
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&numffc,f,true))
17259 return qe_invalid;
17260 }
17261 byte tempbyte;
17262 word tempw;
17263
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
36 static ffcdata nil_ffc;
17264
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 661 times.
697 for(word m = 0; m < numffc; ++m)
17265 {
17266
1/2
✓ Branch 0 taken 661 times.
✗ Branch 1 not taken.
661 ffcdata& tempffc = (m < MAXFFCS)
17267 661 ? temp_mapscr->ffcs[m]
17268 : nil_ffc; //sanity
17269 661 tempffc.clear();
17270
3/4
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 352 times.
661 if(old_ff && !(bits & (1<<m))) continue;
17271
17272
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if(!p_igetw(&tempw,f,true))
17273 return qe_invalid;
17274
3/4
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 267 times.
309 if(!old_ff && !tempw) //empty ffc, nothing more to load
17275 267 continue;
17276 42 tempffc.setData(tempw);
17277
17278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_getc(&(tempffc.cset),f,true))
17279 return qe_invalid;
17280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetw(&(tempffc.delay),f,true))
17281 return qe_invalid;
17282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetzf(&(tempffc.x),f,true))
17283 return qe_invalid;
17284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetzf(&(tempffc.y),f,true))
17285 return qe_invalid;
17286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetzf(&(tempffc.vx),f,true))
17287 return qe_invalid;
17288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetzf(&(tempffc.vy),f,true))
17289 return qe_invalid;
17290
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_igetzf(&(tempffc.ax),f,true))
17291 return qe_invalid;
17292
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_igetzf(&(tempffc.ay),f,true))
17293 return qe_invalid;
17294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_getc(&(tempffc.link),f,true))
17295 return qe_invalid;
17296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(version < 24)
17297 {
17298 if(!p_getc(&tempbyte,f,true))
17299 return qe_invalid;
17300 tempffc.hxsz = (tempbyte&0x3F)+1;
17301 tempffc.txsz = (tempbyte>>6)+1;
17302 if(!p_getc(&tempbyte,f,true))
17303 return qe_invalid;
17304 tempffc.hysz = (tempbyte&0x3F)+1;
17305 tempffc.tysz = (tempbyte>>6)+1;
17306 }
17307 else
17308 {
17309
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_igetl(&(tempffc.hxsz),f,true))
17310 return qe_invalid;
17311
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_igetl(&(tempffc.hysz),f,true))
17312 return qe_invalid;
17313
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_getc(&(tempffc.txsz),f,true))
17314 return qe_invalid;
17315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_getc(&(tempffc.tysz),f,true))
17316 return qe_invalid;
17317 }
17318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetl(&(tempffc.flags),f,true))
17319 return qe_invalid;
17320 42 tempffc.updateSolid();
17321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_igetw(&(tempffc.script),f,true))
17322 return qe_invalid;
17323
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 42 times.
378 for(auto q = 0; q < 8; ++q)
17324 {
17325
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_igetl(&(tempffc.initd[q]),f,true))
17326 return qe_invalid;
17327 336 }
17328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(!p_getc(&(tempbyte),f,true))
17329 return qe_invalid;
17330 42 tempffc.inita[0]=tempbyte*10000;
17331
17332
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(!p_getc(&(tempbyte),f,true))
17333 return qe_invalid;
17334 42 tempffc.inita[1]=tempbyte*10000;
17335
17336 42 tempffc.initialized = false;
17337 42 }
17338
2/2
✓ Branch 0 taken 3947 times.
✓ Branch 1 taken 36 times.
3983 for(word m = numffc; m < MAXFFCS; ++m)
17339 {
17340 3947 temp_mapscr->ffcs[m].clear();
17341 3947 }
17342 36 temp_mapscr->update_ffc_count(numffc-1);
17343 //END FFC
17344 }
17345 8876 return 0;
17346 9384 }
17347
17348
17349 13 int32_t readmaps(PACKFILE *f, zquestheader *Header, bool keepdata)
17350 {
17351 13 int32_t scr=0;
17352
17353 13 word version=0;
17354 dword dummy;
17355 int32_t screens_to_read;
17356
17357 13 mapscr temp_mapscr;
17358 zcmap temp_map;
17359 word temp_map_count;
17360 dword section_size;
17361
17362
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17363 {
17364 screens_to_read=MAPSCRS192b136;
17365 }
17366 else
17367 {
17368 13 screens_to_read=MAPSCRS;
17369 }
17370
17371
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Header->zelda_version > 0x192)
17372 {
17373 //section version info
17374
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&version,f,true))
17375 {
17376 return qe_invalid;
17377 }
17378
17379 13 FFCore.quest_format[vMaps] = version;
17380
17381 //al_trace("Maps version %d\n", version);
17382
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&dummy,f,true))
17383 {
17384 return qe_invalid;
17385 }
17386
17387 //section size
17388
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetl(&section_size,f,true))
17389 {
17390 return qe_invalid;
17391 }
17392
17393 //finally... section data
17394
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_map_count,f,true))
17395 {
17396 return 5;
17397 }
17398 13 }
17399 else
17400 {
17401 temp_map_count=map_count;
17402 }
17403
17404
17405
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(keepdata)
17406 {
17407 13 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17408
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 TheMaps.resize(_mapsSize);
17409
17410
2/2
✓ Branch 0 taken 9384 times.
✓ Branch 1 taken 13 times.
9397 for(int32_t i(0); i<_mapsSize; i++)
17411
1/2
✓ Branch 0 taken 9384 times.
✗ Branch 1 not taken.
9384 TheMaps[i].zero_memory();
17412
17413 // Used to be done for each screen
17414
2/2
✓ Branch 0 taken 1664 times.
✓ Branch 1 taken 13 times.
1677 for(int32_t i=0; i<MAXFFCS; i++)
17415 {
17416 1664 ffcScriptData[i].a[0] = 10000;
17417 1664 ffcScriptData[i].a[1] = 10000;
17418 1664 }
17419
17420 13 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17421 13 }
17422
17423
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 temp_mapscr.zero_memory();
17424
17425 13 memset(&temp_map, 0, sizeof(zcmap));
17426 13 temp_map.scrResWidth = 256;
17427 13 temp_map.scrResHeight = 224;
17428 13 temp_map.tileWidth = 16;
17429 13 temp_map.tileHeight = 11;
17430 13 temp_map.viewWidth = 256;
17431 13 temp_map.viewHeight = 176;
17432 13 temp_map.viewX = 0;
17433 13 temp_map.viewY = 64;
17434 13 temp_map.subaWidth = 256;
17435 13 temp_map.subaHeight = 168;
17436 13 temp_map.subaTrans = false;
17437 13 temp_map.subpWidth = 256;
17438 13 temp_map.subpHeight = 56;
17439 13 temp_map.subpTrans = false;
17440
4/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 69 times.
82 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17441 {
17442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(keepdata==true) //!TODO Trim fully
17443 {
17444 69 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17445 69 }
17446 69 byte valid=1;
17447
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 65 times.
69 if(version > 22)
17448 {
17449
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!p_getc(&valid,f,true))
17450 return qe_invalid;
17451 4 }
17452
2/2
✓ Branch 0 taken 9384 times.
✓ Branch 1 taken 69 times.
9453 for(int32_t j=0; j<screens_to_read; j++)
17453 {
17454 9384 scr=i*MAPSCRS+j;
17455
1/2
✓ Branch 0 taken 9384 times.
✗ Branch 1 not taken.
9384 clear_screen(&temp_mapscr);
17456
1/2
✓ Branch 0 taken 9384 times.
✗ Branch 1 not taken.
9384 if(valid)
17457
1/2
✓ Branch 0 taken 9384 times.
✗ Branch 1 not taken.
9384 readmapscreen(f, Header, &temp_mapscr, &temp_map, version);
17458
17459
1/2
✓ Branch 0 taken 9384 times.
✗ Branch 1 not taken.
9384 if(keepdata==true)
17460 {
17461
1/2
✓ Branch 0 taken 9384 times.
✗ Branch 1 not taken.
9384 TheMaps[scr] = temp_mapscr;
17462 9384 }
17463 9384 }
17464
17465
1/2
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
69 if(keepdata==true)
17466 {
17467
2/6
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 69 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
69 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17468 {
17469 int32_t index = (i*MAPSCRS+132);
17470
17471 TheMaps[index]=TheMaps[index-1];
17472
17473 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17474 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17475 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17476
17477 for(int32_t j=133; j<MAPSCRS; j++)
17478 {
17479 scr=i*MAPSCRS+j;
17480
17481 TheMaps[scr].zero_memory();
17482 TheMaps[scr].valid = mVERSION;
17483 TheMaps[scr].screen_midi = -1;
17484 TheMaps[scr].csensitive = 1;
17485 }
17486 }
17487
17488
2/6
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 69 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
69 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17489 {
17490 for(int32_t j=0; j<MAPSCRS; j++)
17491 {
17492 scr=i*MAPSCRS+j;
17493 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17494
17495 for(int32_t k=0; k<128; k++)
17496 {
17497 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17498 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17499 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17500 }
17501 }
17502 }
17503 69 }
17504 69 }
17505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata)
17506 {
17507 13 map_count = temp_map_count;
17508 13 }
17509
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 clear_screen(&temp_mapscr);
17510 13 return 0;
17511 13 }
17512
17513
17514 11 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos, bool keepdata)
17515 {
17516 11 reset_combo_animations();
17517 11 reset_combo_animations2();
17518
17519 11 init_combo_classes();
17520
17521 // combos
17522 11 word combos_used=0;
17523 int32_t dummy;
17524 byte padding;
17525 11 newcombo temp_combo;
17526 //word section_cversion=0;
17527
17528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(keepdata==true)
17529 {
17530
2/2
✓ Branch 0 taken 718080 times.
✓ Branch 1 taken 11 times.
718091 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17531 718080 combobuf[q].clear();
17532 11 }
17533
17534 // if(version > 0x192)
17535 // {
17536 // //section version info
17537 // if(!p_igetw(&section_version,f,true))
17538 // {
17539 // return qe_invalid;
17540 // }
17541
17542 // FFCore.quest_format[vCombos] = section_version;
17543
17544 // //al_trace("Combos version %d\n", section_version);
17545 // if(!p_igetw(&section_cversion,f,true))
17546 // {
17547 // return qe_invalid;
17548 // }
17549
17550 // //section size
17551 // if(!p_igetl(&dummy,f,true))
17552 // {
17553 // return qe_invalid;
17554 // }
17555 // }
17556
17557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(version < 0x174)
17558 {
17559 combos_used=1024;
17560 }
17561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 else if(version < 0x191)
17562 {
17563 combos_used=2048;
17564 }
17565 else
17566 {
17567
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetw(&combos_used,f,true))
17568 {
17569 return qe_invalid;
17570 }
17571 }
17572
17573 //finally... section data
17574
2/2
✓ Branch 0 taken 12720 times.
✓ Branch 1 taken 11 times.
12731 for(int32_t i=0; i<combos_used; i++)
17575 {
17576 12720 temp_combo.clear();
17577
17578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if ( section_version >= 11 )
17579 {
17580 if(!p_igetl(&temp_combo.tile,f,true))
17581 {
17582 return qe_invalid;
17583 }
17584 }
17585 else
17586 {
17587
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(!p_igetw(&temp_combo.tile,f,true))
17588 {
17589 return qe_invalid;
17590 }
17591 }
17592 12720 temp_combo.o_tile = temp_combo.tile;
17593
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(!p_getc(&temp_combo.flip,f,true))
17594 {
17595 return qe_invalid;
17596 }
17597
17598
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(!p_getc(&temp_combo.walk,f,true))
17599 {
17600 return qe_invalid;
17601 }
17602
17603
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(!p_getc(&temp_combo.type,f,true))
17604 {
17605 return qe_invalid;
17606 }
17607
17608
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(!p_getc(&temp_combo.csets,f,true))
17609 {
17610 return qe_invalid;
17611 }
17612
17613
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(version < 0x193)
17614 {
17615 if(!p_getc(&padding,f,true))
17616 {
17617 return qe_invalid;
17618 }
17619
17620 if(!p_getc(&padding,f,true))
17621 {
17622 return qe_invalid;
17623 }
17624
17625 if(version < 0x192)
17626 {
17627 if(version == 0x191)
17628 {
17629 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17630 {
17631 if(!p_getc(&padding,f,true))
17632 {
17633 return qe_invalid;
17634 }
17635 }
17636 }
17637
17638 if(keepdata==true)
17639 {
17640 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
17641 }
17642
17643 continue;
17644 }
17645 }
17646
17647
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(!p_getc(&temp_combo.frames,f,true))
17648 {
17649 return qe_invalid;
17650 }
17651
17652
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(!p_getc(&temp_combo.speed,f,true))
17653 {
17654 return qe_invalid;
17655 }
17656
17657
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(!p_igetw(&temp_combo.nextcombo,f,true))
17658 {
17659 return qe_invalid;
17660 }
17661
17662
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(!p_getc(&temp_combo.nextcset,f,true))
17663 {
17664 return qe_invalid;
17665 }
17666
17667 //Base flag
17668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version>=3)
17669 {
17670
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(!p_getc(&temp_combo.flag,f,true))
17671 {
17672 return qe_invalid;
17673 }
17674 12720 }
17675
17676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version>=4)
17677 {
17678
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(!p_getc(&temp_combo.skipanim,f,true))
17679 {
17680 return qe_invalid;
17681 }
17682
17683
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(!p_igetw(&temp_combo.nexttimer,f,true))
17684 {
17685 return qe_invalid;
17686 }
17687 12720 }
17688
17689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version>=5)
17690 {
17691
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(!p_getc(&temp_combo.skipanimy,f,true))
17692 {
17693 return qe_invalid;
17694 }
17695 12720 }
17696
17697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version>=6)
17698 {
17699
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(!p_getc(&temp_combo.animflags,f,true))
17700 {
17701 return qe_invalid;
17702 }
17703
17704
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(section_version == 6)
17705 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17706 12720 }
17707
17708
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(section_version>=8) //combo Attributes[4] and userflags.
17709 {
17710 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17711 {
17712 if(!p_igetl(&temp_combo.attributes[q],f,true))
17713 {
17714 return qe_invalid;
17715 }
17716 }
17717 if(!p_igetl(&temp_combo.usrflags,f,true))
17718 {
17719 return qe_invalid;
17720 }
17721 if(section_version >= 20)
17722 {
17723 if(!p_igetw(&temp_combo.genflags,f,true))
17724 {
17725 return qe_invalid;
17726 }
17727 }
17728 else
17729 {
17730 temp_combo.genflags = 0;
17731 switch(temp_combo.type)
17732 {
17733 case cPUSH_WAIT: case cPUSH_HEAVY:
17734 case cPUSH_HW: case cL_STATUE:
17735 case cR_STATUE: case cPUSH_HEAVY2:
17736 case cPUSH_HW2: case cPOUND:
17737 case cC_STATUE: case cMIRROR:
17738 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17739 case cMAGICPRISM: case cMAGICPRISM4:
17740 case cMAGICSPONGE: case cEYEBALL_A:
17741 case cEYEBALL_B: case cEYEBALL_4:
17742 case cBUSH: case cFLOWERS:
17743 case cLOCKBLOCK: case cLOCKBLOCK2:
17744 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17745 case cCHEST: case cCHEST2:
17746 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17747 case cBOSSCHEST: case cBOSSCHEST2:
17748 case cBUSHNEXT: case cBUSHTOUCHY:
17749 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17750 case cSIGNPOST: case cCSWITCHBLOCK:
17751 case cTORCH: case cTRIGGERGENERIC:
17752 if(temp_combo.usrflags & cflag16)
17753 {
17754 temp_combo.genflags |= cflag1;
17755 temp_combo.usrflags &= ~cflag16;
17756 }
17757 break; }
17758 }
17759 }
17760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version>=10) //combo trigger flags
17761 {
17762 for ( int32_t q = 0; q < 3; q++ )
17763 {
17764 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17765 {
17766 return qe_invalid;
17767 }
17768 }
17769 }
17770
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17771 {
17772 for ( int32_t q = 0; q < 2; q++ )
17773 {
17774 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17775 {
17776 return qe_invalid;
17777 }
17778 }
17779 }
17780
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(section_version >= 9)
17781 {
17782 if(!p_igetl(&temp_combo.triggerlevel,f,true))
17783 {
17784 return qe_invalid;
17785 }
17786 }
17787
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(section_version >= 22)
17788 {
17789 if(!p_getc(&temp_combo.triggerbtn,f,true))
17790 {
17791 return qe_invalid;
17792 }
17793 }
17794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version < 23)
17795 {
17796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17797 {
17798 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17799 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17800 case cTRIGGERGENERIC: case cCSWITCH:
17801 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17802 }
17803 12720 }
17804
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(section_version >= 24)
17805 {
17806 if(!p_getc(&temp_combo.triggeritem,f,true))
17807 {
17808 return qe_invalid;
17809 }
17810 if(!p_getc(&temp_combo.trigtimer,f,true))
17811 {
17812 return qe_invalid;
17813 }
17814 }
17815
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(section_version >= 25)
17816 {
17817 if(!p_getc(&temp_combo.trigsfx,f,true))
17818 {
17819 return qe_invalid;
17820 }
17821 }
17822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version >= 27)
17823 {
17824 if(!p_igetl(&temp_combo.trigchange,f,true))
17825 {
17826 return qe_invalid;
17827 }
17828 }
17829 else
17830 {
17831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17832 temp_combo.trigchange = 1;
17833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17834 temp_combo.trigchange = -1;
17835 12720 else temp_combo.trigchange = 0;
17836 12720 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17837 }
17838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version >= 29)
17839 {
17840 if(!p_igetw(&temp_combo.trigprox,f,true))
17841 {
17842 return qe_invalid;
17843 }
17844 if(!p_getc(&temp_combo.trigctr,f,true))
17845 {
17846 return qe_invalid;
17847 }
17848 if(!p_igetl(&temp_combo.trigctramnt,f,true))
17849 {
17850 return qe_invalid;
17851 }
17852 }
17853 else
17854 {
17855 12720 temp_combo.trigprox = 0;
17856 12720 temp_combo.trigctr = 0;
17857 12720 temp_combo.trigctramnt = 0;
17858 }
17859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version >= 30)
17860 {
17861 if(!p_getc(&temp_combo.triglbeam,f,true))
17862 {
17863 return qe_invalid;
17864 }
17865 }
17866 12720 else temp_combo.triglbeam = 0;
17867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version >= 31)
17868 {
17869 if(!p_getc(&temp_combo.trigcschange,f,true))
17870 {
17871 return qe_invalid;
17872 }
17873 if(!p_igetw(&temp_combo.spawnitem,f,true))
17874 {
17875 return qe_invalid;
17876 }
17877 if(!p_igetw(&temp_combo.spawnenemy,f,true))
17878 {
17879 return qe_invalid;
17880 }
17881 if(!p_getc(&temp_combo.exstate,f,true))
17882 {
17883 return qe_invalid;
17884 }
17885 if(!p_igetl(&temp_combo.spawnip,f,true))
17886 {
17887 return qe_invalid;
17888 }
17889 if(!p_getc(&temp_combo.trigcopycat,f,true))
17890 {
17891 return qe_invalid;
17892 }
17893 }
17894 else
17895 {
17896 12720 temp_combo.trigcschange = 0;
17897 12720 temp_combo.spawnitem = 0;
17898 12720 temp_combo.spawnenemy = 0;
17899 12720 temp_combo.exstate = -1;
17900 12720 temp_combo.spawnip = 0;
17901 12720 temp_combo.trigcopycat = 0;
17902 }
17903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version >= 32)
17904 {
17905 if(!p_getc(&temp_combo.trigcooldown,f,true))
17906 {
17907 return qe_invalid;
17908 }
17909 }
17910 else
17911 {
17912 12720 temp_combo.trigcooldown = 0;
17913 }
17914
17915
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(section_version>=12) //combo label
17916 {
17917 for ( int32_t q = 0; q < 11; q++ )
17918 {
17919 if(!p_getc(&temp_combo.label[q],f,true))
17920 {
17921 return qe_invalid;
17922 }
17923 }
17924 }
17925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version<12) //combo label
17926 {
17927
2/2
✓ Branch 0 taken 139920 times.
✓ Branch 1 taken 12720 times.
152640 for ( int32_t q = 0; q < 11; q++ )
17928 {
17929 139920 temp_combo.label[q] = 0;
17930 139920 }
17931 12720 }
17932 //al_trace("Read combo label\n");
17933
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(section_version>=13) //attribytes[4]
17934 {
17935 for ( int32_t q = 0; q < 4; q++ ) //Bad Zoria, don't mix constants with hardcodes
17936 {
17937 if(!p_getc(&temp_combo.attribytes[q],f,true))
17938 {
17939 return qe_invalid;
17940 }
17941 }
17942
17943 }
17944 //al_trace("Read combo attribytes\n");
17945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if( section_version < 13 )
17946 {
17947
2/2
✓ Branch 0 taken 50880 times.
✓ Branch 1 taken 12720 times.
63600 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17948 {
17949 50880 temp_combo.attribytes[q] = 0;
17950 50880 }
17951
17952 12720 }
17953 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17954 * This fixes a poor implementation of a ->next flag bug thing.
17955 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17956 * there was a version bump a few weeks before a change that broke stuff.
17957 */
17958
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12720 if (section_version >= 13 && section_version < 21)
17959 {
17960 set_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17961 }
17962 //combo scripts
17963
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(section_version>=14)
17964 {
17965 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
17966 for ( int32_t q = 0; q < 2; q++ )
17967 {
17968 if(!p_igetl(&temp_combo.initd[q],f,true))
17969 {
17970 return qe_invalid;
17971 }
17972 }
17973
17974 }
17975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version<14)
17976 {
17977 12720 temp_combo.script = 0;
17978
2/2
✓ Branch 0 taken 25440 times.
✓ Branch 1 taken 12720 times.
38160 for ( int32_t q = 0; q < 2; q++ )
17979 {
17980 25440 temp_combo.initd[q] = 0;
17981 25440 }
17982 12720 }
17983 //al_trace("Read combo script data\n");
17984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version>=15)
17985 {
17986 if(!p_igetl(&temp_combo.o_tile,f,true)) return qe_invalid;
17987 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17988 if(!p_getc(&temp_combo.cur_frame,f,true)) return qe_invalid;
17989 if(!p_getc(&temp_combo.aclk,f,true)) return qe_invalid;
17990 }
17991 else
17992 {
17993 12720 temp_combo.o_tile = temp_combo.tile;
17994 12720 temp_combo.cur_frame = 0;
17995 12720 temp_combo.aclk = 0;
17996 }
17997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version>=17) //attribytes[4]
17998 {
17999 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
18000 {
18001 if(!p_getc(&temp_combo.attribytes[q],f,true))
18002 {
18003 return qe_invalid;
18004 }
18005 }
18006 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
18007 {
18008 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18009 {
18010 return qe_invalid;
18011 }
18012 }
18013
18014 }
18015 else
18016 {
18017
2/2
✓ Branch 0 taken 50880 times.
✓ Branch 1 taken 12720 times.
63600 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
18018 {
18019 50880 temp_combo.attribytes[q] = 0;
18020 50880 }
18021
2/2
✓ Branch 0 taken 101760 times.
✓ Branch 1 taken 12720 times.
114480 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
18022 {
18023 101760 temp_combo.attrishorts[q] = 0;
18024 101760 }
18025 }
18026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version<18) //upper bits for .walk
18027 {
18028 12720 temp_combo.walk |= 0xF0; //All on by default for old quests -E
18029 12720 }
18030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version < 19)
18031 {
18032
2/2
✓ Branch 0 taken 50880 times.
✓ Branch 1 taken 12720 times.
63600 for(int32_t q = 0; q < 4; ++q)
18033 {
18034 50880 temp_combo.attributes[q] *= 10000L;
18035 50880 }
18036 12720 }
18037
18038
1/2
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
12720 if(version < 0x193)
18039 {
18040 for(int32_t q=0; q<11; q++)
18041 {
18042 if(!p_getc(&dummy,f,true))
18043 {
18044 return qe_invalid;
18045 }
18046 }
18047 }
18048
18049 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
18050
2/6
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12720 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12720 if((version < 0x211)||((version == 0x211)&&(build<7)))
18051 {
18052 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
18053 {
18054 switch(temp_combo.tile)
18055 {
18056 case 130:
18057 temp_combo.tile = 132;
18058 break;
18059
18060 case 131:
18061 temp_combo.tile = 133;
18062 break;
18063
18064 case 132:
18065 temp_combo.tile = 130;
18066 break;
18067
18068 case 133:
18069 temp_combo.tile = 131;
18070 break;
18071 }
18072 }
18073 }
18074
18075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version < 25)
18076 {
18077
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 12631 times.
12720 switch(temp_combo.type)
18078 {
18079 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
18080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(!(temp_combo.usrflags & cflag3))
18081 89 temp_combo.attribytes[3] = WAV_DOOR;
18082 89 temp_combo.usrflags &= ~cflag3;
18083 89 break;
18084 }
18085 12720 }
18086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version < 26)
18087 {
18088
2/2
✓ Branch 0 taken 12686 times.
✓ Branch 1 taken 34 times.
12720 if(temp_combo.type == cARMOS)
18089 {
18090
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(temp_combo.usrflags & cflag1)
18091 temp_combo.usrflags |= cflag3;
18092 34 }
18093 12720 }
18094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 if(section_version < 28)
18095 {
18096
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 12675 times.
12720 switch(temp_combo.type)
18097 {
18098 case cLOCKBLOCK: case cLOCKEDCHEST:
18099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(temp_combo.usrflags & cflag7)
18100 temp_combo.usrflags |= cflag8;
18101 45 else temp_combo.usrflags &= ~cflag8;
18102 45 temp_combo.usrflags &= ~cflag7;
18103 45 break;
18104 }
18105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12720 times.
12720 switch(temp_combo.type)
18106 {
18107 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18108 temp_combo.attrishorts[2] = -1;
18109 temp_combo.usrflags |= cflag7;
18110 break;
18111 }
18112 12720 }
18113
18114
2/4
✓ Branch 0 taken 12720 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12720 times.
12720 if(keepdata==true && i>=start_combo)
18115 {
18116 12720 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18117 12720 }
18118 12720 }
18119
18120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(keepdata==true)
18121 {
18122
2/6
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18123 {
18124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18125 {
18126 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18127 {
18128 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18129 }
18130 }
18131 }
18132
18133 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18134
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(version == 0x210 && !is_zquest())
18135 {
18136 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18137 if(combobuf[tmpcounter].type == cLADDERONLY)
18138 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18139 }
18140
18141
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(section_version<7)
18142 {
18143 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18144 {
18145 switch(combobuf[tmpcounter].type)
18146 {
18147 case cSLASH:
18148 combobuf[tmpcounter].type=cSLASHTOUCHY;
18149 break;
18150
18151 case cSLASHITEM:
18152 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18153 break;
18154
18155 case cBUSH:
18156 combobuf[tmpcounter].type=cBUSHTOUCHY;
18157 break;
18158
18159 case cFLOWERS:
18160 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18161 break;
18162
18163 case cTALLGRASS:
18164 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18165 break;
18166
18167 case cSLASHNEXT:
18168 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18169 break;
18170
18171 case cSLASHNEXTITEM:
18172 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18173 break;
18174
18175 case cBUSHNEXT:
18176 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18177 break;
18178 }
18179 }
18180 }
18181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (section_version < 16)
18182 {
18183
2/2
✓ Branch 0 taken 718080 times.
✓ Branch 1 taken 11 times.
718091 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18184 {
18185
2/2
✓ Branch 0 taken 717789 times.
✓ Branch 1 taken 291 times.
718080 if (combobuf[tmpcounter].type == cWATER)
18186 {
18187 291 combobuf[tmpcounter].attributes[0] = 40000L;
18188 291 }
18189 718080 }
18190 11 }
18191
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18192 {
18193 combobuf[0].walk = 0xF0;
18194 combobuf[0].type = 0;
18195 combobuf[0].flag = 0;
18196 }
18197 11 }
18198
18199 //Now for the new combo alias reset
18200
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(section_version<2 && keepdata)
18201 {
18202 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18203 {
18204 combo_aliases[j].width = 0;
18205 combo_aliases[j].height = 0;
18206 combo_aliases[j].layermask = 0;
18207
18208 if(combo_aliases[j].combos != NULL)
18209 {
18210 delete[] combo_aliases[j].combos;
18211 }
18212
18213 if(combo_aliases[j].csets != NULL)
18214 {
18215 delete[] combo_aliases[j].csets;
18216 }
18217
18218 combo_aliases[j].combos = new word[1];
18219 combo_aliases[j].csets = new byte[1];
18220 combo_aliases[j].combos[0] = 0;
18221 combo_aliases[j].csets[0] = 0;
18222 }
18223 }
18224
18225
18226 11 setup_combo_animations();
18227 11 setup_combo_animations2();
18228 11 return 0;
18229 11 }
18230 10248 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18231 {
18232 byte combo_has_flags;
18233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10248 times.
10248 if(!p_getc(&combo_has_flags,f,true))
18234 return qe_invalid;
18235
18236 10248 temp_combo.clear();
18237
2/2
✓ Branch 0 taken 7087 times.
✓ Branch 1 taken 3161 times.
10248 if(combo_has_flags)
18238 {
18239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3161 times.
3161 if(combo_has_flags&CHAS_GENERAL)
18240 {
18241
1/2
✓ Branch 0 taken 3161 times.
✗ Branch 1 not taken.
3161 if(!p_igetl(&temp_combo.tile,f,true))
18242 {
18243 return qe_invalid;
18244 }
18245 3161 temp_combo.o_tile = temp_combo.tile;
18246
18247
1/2
✓ Branch 0 taken 3161 times.
✗ Branch 1 not taken.
3161 if(!p_getc(&temp_combo.flip,f,true))
18248 {
18249 return qe_invalid;
18250 }
18251
18252
1/2
✓ Branch 0 taken 3161 times.
✗ Branch 1 not taken.
3161 if(!p_getc(&temp_combo.walk,f,true))
18253 {
18254 return qe_invalid;
18255 }
18256
18257
1/2
✓ Branch 0 taken 3161 times.
✗ Branch 1 not taken.
3161 if(!p_getc(&temp_combo.type,f,true))
18258 {
18259 return qe_invalid;
18260 }
18261
18262
1/2
✓ Branch 0 taken 3161 times.
✗ Branch 1 not taken.
3161 if(!p_getc(&temp_combo.flag,f,true))
18263 {
18264 return qe_invalid;
18265 }
18266
18267
1/2
✓ Branch 0 taken 3161 times.
✗ Branch 1 not taken.
3161 if(!p_getc(&temp_combo.csets,f,true))
18268 {
18269 return qe_invalid;
18270 }
18271 3161 }
18272
2/2
✓ Branch 0 taken 3160 times.
✓ Branch 1 taken 1 times.
3161 if(combo_has_flags&CHAS_SCRIPT)
18273 {
18274
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 for ( int32_t q = 0; q < 11; q++ )
18275 {
18276
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_getc(&temp_combo.label[q],f,true))
18277 {
18278 return qe_invalid;
18279 }
18280 11 }
18281
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
18282
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for ( int32_t q = 0; q < 2; q++ )
18283 {
18284
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetl(&temp_combo.initd[q],f,true))
18285 {
18286 return qe_invalid;
18287 }
18288 2 }
18289 1 }
18290
2/2
✓ Branch 0 taken 2673 times.
✓ Branch 1 taken 488 times.
3161 if(combo_has_flags&CHAS_ANIM)
18291 {
18292
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(!p_getc(&temp_combo.frames,f,true))
18293 {
18294 return qe_invalid;
18295 }
18296
18297
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(!p_getc(&temp_combo.speed,f,true))
18298 {
18299 return qe_invalid;
18300 }
18301
18302
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(!p_igetw(&temp_combo.nextcombo,f,true))
18303 {
18304 return qe_invalid;
18305 }
18306
18307
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(!p_getc(&temp_combo.nextcset,f,true))
18308 {
18309 return qe_invalid;
18310 }
18311
18312
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(!p_getc(&temp_combo.skipanim,f,true))
18313 {
18314 return qe_invalid;
18315 }
18316
18317
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(!p_getc(&temp_combo.skipanimy,f,true))
18318 {
18319 return qe_invalid;
18320 }
18321
18322
1/2
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
488 if(!p_getc(&temp_combo.animflags,f,true))
18323 {
18324 return qe_invalid;
18325 }
18326 488 }
18327
2/2
✓ Branch 0 taken 2737 times.
✓ Branch 1 taken 424 times.
3161 if(combo_has_flags&CHAS_ATTRIB)
18328 {
18329
2/2
✓ Branch 0 taken 1696 times.
✓ Branch 1 taken 424 times.
2120 for ( int32_t q = 0; q < 4; q++ )
18330 {
18331
1/2
✓ Branch 0 taken 1696 times.
✗ Branch 1 not taken.
1696 if(!p_igetl(&temp_combo.attributes[q],f,true))
18332 {
18333 return qe_invalid;
18334 }
18335 1696 }
18336
2/2
✓ Branch 0 taken 3392 times.
✓ Branch 1 taken 424 times.
3816 for ( int32_t q = 0; q < 8; q++ )
18337 {
18338
1/2
✓ Branch 0 taken 3392 times.
✗ Branch 1 not taken.
3392 if(!p_getc(&temp_combo.attribytes[q],f,true))
18339 {
18340 return qe_invalid;
18341 }
18342 3392 }
18343
2/2
✓ Branch 0 taken 3392 times.
✓ Branch 1 taken 424 times.
3816 for ( int32_t q = 0; q < 8; q++ )
18344 {
18345
1/2
✓ Branch 0 taken 3392 times.
✗ Branch 1 not taken.
3392 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18346 {
18347 return qe_invalid;
18348 }
18349 3392 }
18350 424 }
18351
2/2
✓ Branch 0 taken 3027 times.
✓ Branch 1 taken 134 times.
3161 if(combo_has_flags&CHAS_FLAG)
18352 {
18353
1/2
✓ Branch 0 taken 134 times.
✗ Branch 1 not taken.
134 if(!p_igetl(&temp_combo.usrflags,f,true))
18354 {
18355 return qe_invalid;
18356 }
18357
1/2
✓ Branch 0 taken 134 times.
✗ Branch 1 not taken.
134 if(!p_igetw(&temp_combo.genflags,f,true))
18358 {
18359 return qe_invalid;
18360 }
18361 134 }
18362
2/2
✓ Branch 0 taken 3143 times.
✓ Branch 1 taken 18 times.
3161 if(combo_has_flags&CHAS_TRIG)
18363 {
18364
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 18 times.
72 for ( int32_t q = 0; q < 3; q++ )
18365 {
18366
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
18367 {
18368 return qe_invalid;
18369 }
18370 54 }
18371
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_combo.triggerlevel,f,true))
18372 {
18373 return qe_invalid;
18374 }
18375
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_combo.triggerbtn,f,true))
18376 {
18377 return qe_invalid;
18378 }
18379
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_combo.triggeritem,f,true))
18380 {
18381 return qe_invalid;
18382 }
18383
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_combo.trigtimer,f,true))
18384 {
18385 return qe_invalid;
18386 }
18387
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_combo.trigsfx,f,true))
18388 {
18389 return qe_invalid;
18390 }
18391
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_combo.trigchange,f,true))
18392 {
18393 return qe_invalid;
18394 }
18395
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_combo.trigprox,f,true))
18396 {
18397 return qe_invalid;
18398 }
18399
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_combo.trigctr,f,true))
18400 {
18401 return qe_invalid;
18402 }
18403
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_combo.trigctramnt,f,true))
18404 {
18405 return qe_invalid;
18406 }
18407
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_combo.triglbeam,f,true))
18408 {
18409 return qe_invalid;
18410 }
18411
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_combo.trigcschange,f,true))
18412 {
18413 return qe_invalid;
18414 }
18415
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_combo.spawnitem,f,true))
18416 {
18417 return qe_invalid;
18418 }
18419
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_combo.spawnenemy,f,true))
18420 {
18421 return qe_invalid;
18422 }
18423
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_combo.exstate,f,true))
18424 {
18425 return qe_invalid;
18426 }
18427
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_combo.spawnip,f,true))
18428 {
18429 return qe_invalid;
18430 }
18431
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_combo.trigcopycat,f,true))
18432 {
18433 return qe_invalid;
18434 }
18435
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_combo.trigcooldown,f,true))
18436 {
18437 return qe_invalid;
18438 }
18439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(s_version >= 35)
18440 {
18441
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_combo.prompt_cid,f,true))
18442 {
18443 return qe_invalid;
18444 }
18445
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_combo.prompt_cs,f,true))
18446 {
18447 return qe_invalid;
18448 }
18449
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_combo.prompt_x,f,true))
18450 {
18451 return qe_invalid;
18452 }
18453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(!p_igetw(&temp_combo.prompt_y,f,true))
18454 {
18455 return qe_invalid;
18456 }
18457 18 }
18458 18 }
18459
2/2
✓ Branch 0 taken 3153 times.
✓ Branch 1 taken 8 times.
3161 if(combo_has_flags&CHAS_LIFT)
18460 {
18461
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&temp_combo.liftcmb,f,true))
18462 return qe_invalid;
18463
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_combo.liftcs,f,true))
18464 return qe_invalid;
18465
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&temp_combo.liftundercmb,f,true))
18466 return qe_invalid;
18467
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_combo.liftundercs,f,true))
18468 return qe_invalid;
18469
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_combo.liftdmg,f,true))
18470 return qe_invalid;
18471
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_combo.liftlvl,f,true))
18472 return qe_invalid;
18473
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_combo.liftitm,f,true))
18474 return qe_invalid;
18475
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_combo.liftflags,f,true))
18476 return qe_invalid;
18477
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_combo.liftgfx,f,true))
18478 return qe_invalid;
18479
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_combo.liftsprite,f,true))
18480 return qe_invalid;
18481
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_combo.liftsfx,f,true))
18482 return qe_invalid;
18483
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_igetw(&temp_combo.liftbreaksprite,f,true))
18484 return qe_invalid;
18485
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_combo.liftbreaksfx,f,true))
18486 return qe_invalid;
18487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(s_version >= 34)
18488 {
18489
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_combo.lifthei,f,true))
18490 return qe_invalid;
18491
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!p_getc(&temp_combo.lifttime,f,true))
18492 return qe_invalid;
18493 8 }
18494 8 }
18495 3161 }
18496 10248 return 0;
18497 10248 }
18498 13 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos, bool keepdata)
18499 {
18500 13 word section_version=0;
18501 13 word section_cversion=0;
18502 13 word combos_used=0;
18503 int32_t dummy;
18504 byte padding;
18505 13 newcombo temp_combo;
18506
18507 13 reset_combo_animations();
18508 13 reset_combo_animations2();
18509 13 init_combo_classes();
18510
18511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata==true) //reset combos
18512 {
18513
2/2
✓ Branch 0 taken 848640 times.
✓ Branch 1 taken 13 times.
848653 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18514 848640 combobuf[q].clear();
18515 13 }
18516
18517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(version > 0x192) //Version info
18518 {
18519
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&section_version,f,true))
18520 {
18521 return qe_invalid;
18522 }
18523 13 FFCore.quest_format[vCombos] = section_version;
18524
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&section_cversion,f,true))
18525 {
18526 return qe_invalid;
18527 }
18528
18529 //section size
18530
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy,f,true))
18531 {
18532 return qe_invalid;
18533 }
18534 13 }
18535
18536
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(section_version > 32) //Cleanup time!
18537 {
18538
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetw(&combos_used,f,true))
18539 {
18540 return qe_invalid;
18541 }
18542
2/2
✓ Branch 0 taken 10248 times.
✓ Branch 1 taken 2 times.
10250 for(int32_t i=0; i<combos_used; i++)
18543 {
18544 10248 auto ret = readcombo_loop(f,section_version,temp_combo);
18545
1/2
✓ Branch 0 taken 10248 times.
✗ Branch 1 not taken.
10248 if(ret) return ret;
18546
2/4
✓ Branch 0 taken 10248 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10248 times.
10248 if(keepdata==true && i>=start_combo)
18547 10248 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18548 10248 }
18549 2 }
18550 else //Call the old function for all old versions
18551 {
18552 11 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos,keepdata);
18553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(ret) return ret; //error, end read
18554 }
18555
18556
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(keepdata && false/*section_version < 34*/)
18557 {
18558 for(int32_t i=start_combo; i<combos_used; i++)
18559 {
18560 newcombo& cmb = combobuf[i];
18561 //Do anything to 'cmb' needed for version handling
18562 }
18563 }
18564
18565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata==true)
18566 {
18567
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18568 {
18569 2 combobuf[0].walk = 0xF0;
18570 2 combobuf[0].type = 0;
18571 2 combobuf[0].flag = 0;
18572 2 }
18573 13 }
18574
18575 13 setup_combo_animations();
18576 13 setup_combo_animations2();
18577 13 return 0;
18578 13 }
18579
18580 13 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build, bool keepdata)
18581 {
18582 //these are here to bypass compiler warnings about unused arguments
18583 13 Header=Header;
18584 13 version=version;
18585 13 build=build;
18586
18587 int32_t dummy;
18588 13 word sversion=0, c_sversion;
18589
18590 //section version info
18591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!p_igetw(&sversion,f,true))
18592 {
18593 return qe_invalid;
18594 }
18595
18596 13 FFCore.quest_format[vComboAliases] = sversion;
18597
18598 //al_trace("Combo aliases version %d\n", sversion);
18599
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&c_sversion,f,true))
18600 {
18601 return qe_invalid;
18602 }
18603
18604 //section size
18605
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy,f,true))
18606 {
18607 return qe_invalid;
18608 }
18609
18610 13 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18611
18612
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18613 {
18614 11 max_num_combo_aliases = MAX250COMBOALIASES;
18615 11 }
18616
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18617 {
18618 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18619 }
18620
18621
2/2
✓ Branch 0 taken 38912 times.
✓ Branch 1 taken 13 times.
38925 for(int32_t j=0; j<max_num_combo_aliases; j++)
18622 {
18623 byte width,height,mask,tempcset;
18624 int32_t count;
18625 word tempword;
18626 byte tempbyte;
18627
18628
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_igetw(&tempword,f,true))
18629 {
18630 return qe_invalid;
18631 }
18632
18633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38912 times.
38912 if(keepdata)
18634 {
18635 38912 combo_aliases[j].combo = tempword;
18636 38912 }
18637
18638
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_getc(&tempbyte,f,true))
18639 {
18640 return qe_invalid;
18641 }
18642
18643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38912 times.
38912 if(keepdata)
18644 {
18645 38912 combo_aliases[j].cset = tempbyte;
18646 38912 }
18647
18648
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_getc(&width,f,true))
18649 {
18650 return qe_invalid;
18651 }
18652
18653
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_getc(&height,f,true))
18654 {
18655 return qe_invalid;
18656 }
18657
18658
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(!p_getc(&mask,f,true))
18659 {
18660 return qe_invalid;
18661 }
18662
18663 38912 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18664
18665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38912 times.
38912 if(keepdata)
18666 {
18667
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(combo_aliases[j].combos != NULL)
18668 {
18669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38912 times.
38912 delete[] combo_aliases[j].combos;
18670 38912 }
18671
18672
1/2
✓ Branch 0 taken 38912 times.
✗ Branch 1 not taken.
38912 if(combo_aliases[j].csets != NULL)
18673 {
18674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38912 times.
38912 delete[] combo_aliases[j].csets;
18675 38912 }
18676
18677 38912 combo_aliases[j].width = width;
18678 38912 combo_aliases[j].height = height;
18679 38912 combo_aliases[j].layermask = mask;
18680 38912 combo_aliases[j].combos = new word[count];
18681 38912 combo_aliases[j].csets = new byte[count];
18682 38912 }
18683
18684
2/2
✓ Branch 0 taken 39408 times.
✓ Branch 1 taken 38912 times.
78320 for(int32_t k=0; k<count; k++)
18685 {
18686
1/2
✓ Branch 0 taken 39408 times.
✗ Branch 1 not taken.
39408 if(!p_igetw(&tempword,f,true))
18687 {
18688 return qe_invalid;
18689 }
18690
18691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39408 times.
39408 if(keepdata)
18692 {
18693 39408 combo_aliases[j].combos[k] = tempword;
18694 39408 }
18695 39408 }
18696
18697
2/2
✓ Branch 0 taken 39408 times.
✓ Branch 1 taken 38912 times.
78320 for(int32_t k=0; k<count; k++)
18698 {
18699
1/2
✓ Branch 0 taken 39408 times.
✗ Branch 1 not taken.
39408 if(!p_getc(&tempcset,f,true))
18700 {
18701 return qe_invalid;
18702 }
18703
18704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39408 times.
39408 if(keepdata)
18705 {
18706 39408 combo_aliases[j].csets[k] = tempcset;
18707 39408 }
18708 39408 }
18709 38912 }
18710
18711 13 word num_combo_pools = 0;
18712
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(sversion >= 4)
18713 {
18714
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetw(&num_combo_pools,f,true))
18715 {
18716 return qe_invalid;
18717 }
18718 2 }
18719
18720
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 13 times.
106509 for(combo_pool& pool : combo_pools)
18721 {
18722 106496 pool.clear();
18723 }
18724
18725 13 combo_pool temp_cpool;
18726
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 13 times.
19 for(word cp = 0; cp < num_combo_pools; ++cp)
18727 {
18728 6 int32_t num_combos_in_pool = 0;
18729
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetl(&num_combos_in_pool,f,true))
18730 {
18731 return qe_invalid;
18732 }
18733
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(num_combos_in_pool < 1) continue; //nothing to read
18734
18735
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 temp_cpool.clear();
18736
18737 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18738
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 6 times.
32 for(auto q = 0; q < num_combos_in_pool; ++q)
18739 {
18740
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 if(!p_igetl(&cp_cid,f,true))
18741 {
18742 return qe_invalid;
18743 }
18744
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 if(!p_getc(&cp_cs,f,true))
18745 {
18746 return qe_invalid;
18747 }
18748
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 if(!p_igetw(&cp_quant,f,true))
18749 {
18750 return qe_invalid;
18751 }
18752
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18753 26 }
18754
18755
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(keepdata)
18756 {
18757
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 combo_pools[cp] = temp_cpool;
18758 6 }
18759 6 }
18760
18761 13 return 0;
18762 13 }
18763
18764 13 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets, bool keepdata)
18765 {
18766 //these are here to bypass compiler warnings about unused arguments
18767
18768 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18769 //Capitalized cause it'll save you a headache. -Deedee
18770 13 start_cset=start_cset;
18771 13 max_csets=max_csets;
18772 13 word s_version=0;
18773
18774 miscQdata temp_misc;
18775 13 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18776
18777 byte temp_colordata[48];
18778 char temp_palname[PALNAMESIZE];
18779
18780 int32_t dummy;
18781 word palcycles;
18782
18783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(version > 0x192)
18784 {
18785 //section version info
18786
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_version,f,true))
18787 {
18788 return qe_invalid;
18789 }
18790
18791 13 FFCore.quest_format[vCSets] = s_version;
18792
18793 //al_trace("Color data version %d\n", s_version);
18794
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&dummy,f,true))
18795 {
18796 return qe_invalid;
18797 }
18798
18799 //section size
18800
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy,f,true))
18801 {
18802 return qe_invalid;
18803 }
18804 13 }
18805
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if (s_version < 5)
18806 {
18807
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18808
18809 //finally... section data
18810 11 int32_t q = 0;
18811 11 int32_t p = -15;
18812
2/2
✓ Branch 0 taken 2640 times.
✓ Branch 1 taken 11 times.
2651 for(int32_t i=0; i<oldpdTOTAL; ++i)
18813 {
18814 2640 memset(temp_colordata, 0, 48);
18815
18816
1/2
✓ Branch 0 taken 2640 times.
✗ Branch 1 not taken.
2640 if(!pfread(temp_colordata,48,f,true))
18817 {
18818 return qe_invalid;
18819 }
18820
18821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2640 times.
2640 if(keepdata==true)
18822 {
18823 2640 memcpy(&colordata[q*48], temp_colordata, 48);
18824 2640 }
18825 2640 ++q;
18826
7/8
✓ Branch 0 taken 2464 times.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 2277 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 165 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 22 times.
2640 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18827 {
18828
1/2
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
187 if (s_version < 5) //Bumping up the size of level palettes
18829 {
18830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187 times.
187 if(keepdata==true)
18831 {
18832 187 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18833 187 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18834 187 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18835 187 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18836 187 }
18837 187 q+=4;
18838 187 }
18839 else
18840 {
18841 for(int m = 0; m < 4; ++m)
18842 {
18843 memset(temp_colordata, 0, 48);
18844 if(!pfread(temp_colordata,48,f,true))
18845 {
18846 return qe_invalid;
18847 }
18848 if(keepdata==true)
18849 {
18850 memcpy(&colordata[q*48], temp_colordata, 48);
18851 }
18852 ++q;
18853 }
18854 }
18855 187 }
18856 2640 ++p;
18857 2640 }
18858
18859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(RealOldVerion)
18860 {
18861 if(keepdata==true)
18862 {
18863 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18864 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18865 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18866 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18867 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18868 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18869 }
18870 }
18871 else
18872 {
18873 11 memset(temp_colordata, 0, 48);
18874
18875
2/2
✓ Branch 0 taken 34463 times.
✓ Branch 1 taken 11 times.
34474 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18876 {
18877
1/2
✓ Branch 0 taken 34463 times.
✗ Branch 1 not taken.
34463 if(!pfread(temp_colordata,48,f,true))
18878 {
18879 return qe_invalid;
18880 }
18881
18882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34463 times.
34463 if(keepdata==true)
18883 {
18884 34463 memcpy(&colordata[q*48], temp_colordata, 48);
18885 34463 }
18886 34463 ++q;
18887
6/8
✓ Branch 0 taken 34463 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2651 times.
✓ Branch 3 taken 31812 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 2629 times.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
34463 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18888 {
18889
1/2
✓ Branch 0 taken 2651 times.
✗ Branch 1 not taken.
2651 if (s_version < 5) //Bumping up the size of level palettes
18890 {
18891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2651 times.
2651 if(keepdata==true)
18892 {
18893 2651 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18894 2651 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18895 2651 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18896 2651 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18897 2651 }
18898 2651 q+=4;
18899 2651 }
18900 else
18901 {
18902 for(int m = 0; m < 4; ++m)
18903 {
18904 memset(temp_colordata, 0, 48);
18905 if(!pfread(temp_colordata,48,f,true))
18906 {
18907 return qe_invalid;
18908 }
18909 if(keepdata==true)
18910 {
18911 memcpy(&colordata[q*48], temp_colordata, 48);
18912 }
18913 ++q;
18914 }
18915 }
18916 2651 }
18917 34463 ++p;
18918 34463 }
18919
18920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(s_version < 4)
18921 {
18922 if(keepdata==true)
18923 {
18924 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18925 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18926 }
18927 }
18928 else
18929 {
18930
2/2
✓ Branch 0 taken 36608 times.
✓ Branch 1 taken 11 times.
36619 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18931 {
18932
1/2
✓ Branch 0 taken 36608 times.
✗ Branch 1 not taken.
36608 if(!pfread(temp_colordata,48,f,true))
18933 {
18934 return qe_invalid;
18935 }
18936
18937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36608 times.
36608 if(keepdata==true)
18938 {
18939 36608 memcpy(&colordata[q*48], temp_colordata, 48);
18940 36608 }
18941 36608 ++q;
18942
5/6
✓ Branch 0 taken 36608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2816 times.
✓ Branch 3 taken 33792 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 2794 times.
36608 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18943 {
18944
1/2
✓ Branch 0 taken 2794 times.
✗ Branch 1 not taken.
2794 if (s_version < 5) //Bumping up the size of level palettes
18945 {
18946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2794 times.
2794 if(keepdata==true)
18947 {
18948 2794 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18949 2794 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18950 2794 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18951 2794 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18952 2794 }
18953 2794 q+=4;
18954 2794 }
18955 else
18956 {
18957 for(int m = 0; m < 4; ++m)
18958 {
18959 memset(temp_colordata, 0, 48);
18960 if(!pfread(temp_colordata,48,f,true))
18961 {
18962 return qe_invalid;
18963 }
18964 if(keepdata==true)
18965 {
18966 memcpy(&colordata[q*48], temp_colordata, 48);
18967 }
18968 ++q;
18969 }
18970 }
18971 2794 }
18972 36608 ++p;
18973 36608 }
18974
18975 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18976 }
18977 }
18978 11 }
18979 else
18980 {
18981
2/2
✓ Branch 0 taken 17498 times.
✓ Branch 1 taken 2 times.
17500 for(int32_t i=0; i<pdTOTAL255; ++i)
18982 {
18983 17498 memset(temp_colordata, 0, 48);
18984
18985
1/2
✓ Branch 0 taken 17498 times.
✗ Branch 1 not taken.
17498 if(!pfread(temp_colordata,48,f,true))
18986 {
18987 return qe_invalid;
18988 }
18989
18990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17498 times.
17498 if(keepdata==true)
18991 {
18992 17498 memcpy(&colordata[i*48], temp_colordata, 48);
18993 17498 }
18994 17498 }
18995 }
18996
18997
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((version < 0x192)||((version == 0x192)&&(build<76)))
18998 {
18999 if(keepdata==true)
19000 {
19001 init_palnames();
19002 }
19003 }
19004 else
19005 {
19006 13 int32_t palnamestoread = 0;
19007
19008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version < 3)
19009 palnamestoread = OLDMAXLEVELS;
19010 else
19011 13 palnamestoread = 512;
19012
19013
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 13 times.
6669 for(int32_t i=0; i<palnamestoread; ++i)
19014 {
19015 6656 memset(temp_palname, 0, PALNAMESIZE);
19016
19017
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!pfread(temp_palname,PALNAMESIZE,f,true))
19018 {
19019 return qe_invalid;
19020 }
19021
19022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6656 times.
6656 if(keepdata==true)
19023 {
19024 6656 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19025 6656 }
19026 6656 }
19027
19028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata)
19029 {
19030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19031 {
19032 memset(palnames[i], 0, PALNAMESIZE);
19033 }
19034 13 }
19035 }
19036
19037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(version > 0x192)
19038 {
19039
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<256; i++)
19040 {
19041
2/2
✓ Branch 0 taken 9984 times.
✓ Branch 1 taken 3328 times.
13312 for(int32_t j=0; j<3; j++)
19042 {
19043 9984 temp_misc.cycles[i][j].first=0;
19044 9984 temp_misc.cycles[i][j].count=0;
19045 9984 temp_misc.cycles[i][j].speed=0;
19046 9984 }
19047 3328 }
19048
19049
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&palcycles,f,true))
19050 {
19051 return qe_invalid;
19052 }
19053
19054
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 13 times.
231 for(int32_t i=0; i<palcycles; i++)
19055 {
19056
2/2
✓ Branch 0 taken 654 times.
✓ Branch 1 taken 218 times.
872 for(int32_t j=0; j<3; j++)
19057 {
19058
1/2
✓ Branch 0 taken 654 times.
✗ Branch 1 not taken.
654 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
19059 {
19060 return qe_invalid;
19061 }
19062 654 }
19063
19064
2/2
✓ Branch 0 taken 654 times.
✓ Branch 1 taken 218 times.
872 for(int32_t j=0; j<3; j++)
19065 {
19066
1/2
✓ Branch 0 taken 654 times.
✗ Branch 1 not taken.
654 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
19067 {
19068 return qe_invalid;
19069 }
19070 654 }
19071
19072
2/2
✓ Branch 0 taken 654 times.
✓ Branch 1 taken 218 times.
872 for(int32_t j=0; j<3; j++)
19073 {
19074
1/2
✓ Branch 0 taken 654 times.
✗ Branch 1 not taken.
654 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
19075 {
19076 return qe_invalid;
19077 }
19078 654 }
19079 218 }
19080
19081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata==true)
19082 {
19083 13 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19084 13 }
19085 13 }
19086
19087 13 return 0;
19088 13 }
19089
19090 13 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init, bool keepdata)
19091 {
19092 13 int32_t tiles_used=0;
19093 13 word section_version = 0;
19094 13 word section_cversion = 0;
19095 13 int32_t section_size= 0;
19096 13 byte *temp_tile = new byte[tilesize(tf32Bit)];
19097
19098 //Tile Expansion
19099 //if ( version >= 0x254 && build >= 41 )
19100
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
13 if (version < 0x254 && build < 41)
19101 {
19102 //al_trace("Build was < 41 when reading tiles\n");
19103 11 max_tiles = ZC250MAXTILES;
19104 11 }
19105
19106 //al_trace("Max Tiles: %d\n", max_tiles);
19107
19108
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19109 {
19110 if(keepdata==true)
19111 {
19112 if(!init_tiles(true, Header))
19113 {
19114 al_trace("Unable to initialize tiles\n");
19115 }
19116 }
19117
19118 delete[] temp_tile;
19119 temp_tile=NULL;
19120 return 0;
19121 }
19122 else
19123 {
19124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(version > 0x192)
19125 {
19126 //section version info
19127
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&section_version,f,true))
19128 {
19129 delete[] temp_tile;
19130 return qe_invalid;
19131 }
19132
19133 13 FFCore.quest_format[vTiles] = section_version;
19134
19135
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&section_cversion,f,true))
19136 {
19137 delete[] temp_tile;
19138 return qe_invalid;
19139 }
19140
19141 //section size
19142
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&section_size,f,true))
19143 {
19144 delete[] temp_tile;
19145 return qe_invalid;
19146 }
19147 13 }
19148
19149 //if ( build < 41 )
19150 //{
19151 // tiles_used = ZC250MAXTILES;
19152 //}
19153
19154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(version < 0x174)
19155 {
19156 tiles_used=TILES_PER_PAGE*4;
19157 } //no expanded tile space
19158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 else if(version < 0x191)
19159 {
19160 tiles_used=OLDMAXTILES;
19161 }
19162 else
19163 {
19164 //finally... section data
19165
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
13 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19166 {
19167
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetl(&tiles_used,f,true))
19168 {
19169 delete[] temp_tile;
19170 return qe_invalid;
19171 }
19172 2 }
19173 else
19174 {
19175
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!p_igetw(&tiles_used,f,true))
19176 {
19177 delete[] temp_tile;
19178 return qe_invalid;
19179 }
19180 }
19181 }
19182
19183
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 tiles_used=zc_min(tiles_used, max_tiles);
19184
19185 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19186 //if ( version < 0x254 && build < 41 )
19187
3/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if ( version < 0x254 || (version == 0x254 && build < 41) )
19188 //if ( build < 41 )
19189 {
19190
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19191 11 }
19192 else //2.55
19193 {
19194
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19195 }
19196
19197 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19198
19199 //al_trace("tiles_used = %d\n", tiles_used);
19200
19201
2/2
✓ Branch 0 taken 194515 times.
✓ Branch 1 taken 13 times.
194528 for(int32_t i=0; i<tiles_used; ++i)
19202 {
19203 194515 byte format=tf4Bit;
19204 194515 memset(temp_tile, 0, tilesize(tf32Bit));
19205
19206
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 194515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
194515 if((version>0x211)||((version==0x211)&&(build>4)))
19207 {
19208
1/2
✓ Branch 0 taken 194515 times.
✗ Branch 1 not taken.
194515 if(!p_getc(&format,f,true))
19209 {
19210 delete[] temp_tile;
19211 return qe_invalid;
19212 }
19213 194515 }
19214
4/4
✓ Branch 0 taken 70156 times.
✓ Branch 1 taken 124359 times.
✓ Branch 2 taken 34845 times.
✓ Branch 3 taken 35311 times.
194515 if(section_version > 2 && !format)
19215 {
19216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35311 times.
35311 if(keepdata)
19217 {
19218 35311 reset_tile(buf,start_tile+i,tf4Bit);
19219 35311 }
19220 35311 continue;
19221 }
19222
19223
1/2
✓ Branch 0 taken 159204 times.
✗ Branch 1 not taken.
159204 if(!pfread(temp_tile,tilesize(format),f,true))
19224 {
19225 delete[] temp_tile;
19226 return qe_invalid;
19227 }
19228
19229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159204 times.
159204 if(keepdata==true)
19230 {
19231 159204 buf[start_tile+i].format=format;
19232
19233
1/2
✓ Branch 0 taken 159204 times.
✗ Branch 1 not taken.
159204 if(buf[start_tile+i].data)
19234 {
19235 159204 free(buf[start_tile+i].data);
19236 159204 buf[start_tile+i].data=NULL;
19237 159204 }
19238
19239 159204 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19240 159204 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19241 159204 }
19242 159204 }
19243 }
19244
19245
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19246 {
19247 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19248
2/2
✓ Branch 0 taken 1638780 times.
✓ Branch 1 taken 11 times.
1638791 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19249 {
19250
19251 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19252 1638780 reset_tile(buf,q,tf4Bit);
19253
19254
19255 /*
19256
19257 byte tempbyte;
19258 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19259 {
19260 tempbyte=buf[ZC250MAXTILES-1].data[i];
19261 buf[q].data[i] = tempbyte;
19262 }
19263 //int32_t temp = tempbyte=buf[130].data[i];
19264 //buf[q].data = buf[ZC250MAXTILES-1].data;
19265 */
19266 //reset_tile(buf,q,tf4Bit);
19267 1638780 }
19268
19269 11 }
19270
19271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata==true)
19272 {
19273
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19274 {
19275
2/2
✓ Branch 0 taken 596361 times.
✓ Branch 1 taken 11 times.
596372 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19276 {
19277 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19278 596361 reset_tile(buf,i,tf4Bit);
19279 596361 }
19280 11 }
19281 else
19282 {
19283
2/2
✓ Branch 0 taken 358844 times.
✓ Branch 1 taken 2 times.
358846 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19284 {
19285 //al_trace("Resetting tiles for build 41+\n");
19286 358844 reset_tile(buf,i,tf4Bit);
19287 358844 }
19288 }
19289
19290
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19291 {
19292 if(get_bit(quest_rules,qr_BSZELDA)) //
19293 {
19294 byte tempbyte;
19295 int32_t floattile=wpnsbuf[iwSwim].tile;
19296
19297 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19298 {
19299 tempbyte=buf[23].data[i];
19300 buf[23].data[i]=buf[24].data[i];
19301 buf[24].data[i]=buf[25].data[i];
19302 buf[25].data[i]=buf[26].data[i];
19303 buf[26].data[i]=tempbyte;
19304 }
19305 //swim tiles are out of order, too, but nobody cared? -Z
19306 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19307 {
19308 tempbyte=buf[floattile+11].data[i];
19309 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19310 buf[floattile+12].data[i]=tempbyte;
19311 }
19312 }
19313 }
19314
19315
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19316 {
19317 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
19318 {
19319 byte tempbyte;
19320
19321 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19322 {
19323 tempbyte=buf[130].data[i];
19324 buf[130].data[i]=buf[132].data[i];
19325 buf[132].data[i]=tempbyte;
19326
19327 tempbyte=buf[131].data[i];
19328 buf[131].data[i]=buf[133].data[i];
19329 buf[133].data[i]=tempbyte;
19330 }
19331 }
19332 }
19333
19334 13 al_trace("Registering blank tiles\n");
19335 13 register_blank_tiles();
19336 13 }
19337
19338 //memset(temp_tile, 0, tilesize(tf32Bit));
19339
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 delete[] temp_tile;
19340 13 temp_tile=NULL;
19341 13 return 0;
19342 13 }
19343
19344 13 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/, bool keepdata)
19345 {
19346 13 byte *mf=midi_flags;
19347 int32_t dummy;
19348 word dummy2;
19349 // zcmidi_ temp_midi;
19350 int32_t tunes_to_read;
19351 13 int32_t tune_count=0;
19352 13 word section_version=0;
19353 13 zctune temp;
19354
19355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(Header->zelda_version < 0x193)
19356 {
19357 // mf=Header->data_flags+ZQ_MIDIS2;
19358 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19359 {
19360 tunes_to_read=MAXCUSTOMMIDIS192b177;
19361 }
19362 else
19363 {
19364 tunes_to_read=MAXCUSTOMTUNES;
19365 }
19366 }
19367 else
19368 {
19369 //section version info
19370
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&section_version,f,true))
19371 {
19372 return qe_invalid;
19373 }
19374
19375 13 FFCore.quest_format[vMIDIs] = section_version;
19376
19377 //al_trace("Tunes version %d\n", section_version);
19378
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&dummy2,f,true))
19379 {
19380 return qe_invalid;
19381 }
19382
19383 //section size
19384
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy,f,true))
19385 {
19386 return qe_invalid;
19387 }
19388
19389 //finally... section data
19390
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!pfread(midi_flags,sizeof(midi_flags),f,true))
19391 {
19392 return qe_invalid;
19393 }
19394
19395 13 tunes_to_read=MAXCUSTOMTUNES;
19396 }
19397
19398
2/2
✓ Branch 0 taken 3276 times.
✓ Branch 1 taken 13 times.
3289 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19399 {
19400
2/2
✓ Branch 0 taken 3186 times.
✓ Branch 1 taken 90 times.
3276 if(get_bit(mf, i))
19401 {
19402 90 ++tune_count;
19403 90 }
19404 3276 }
19405
19406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata==true)
19407 {
19408 13 reset_tunes(tunes); //reset_midis(midis);
19409 13 }
19410
19411
2/2
✓ Branch 0 taken 3276 times.
✓ Branch 1 taken 13 times.
3289 for(int32_t i=0; i<tunes_to_read; i++)
19412 {
19413 3276 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19414
19415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3276 times.
3276 if(keepdata==true)
19416 {
19417 3276 tunes[i].reset(); // reset_midi(midis+i);
19418 3276 }
19419
19420
2/2
✓ Branch 0 taken 3186 times.
✓ Branch 1 taken 90 times.
3276 if(get_bit(mf,i))
19421 {
19422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 if(section_version < 4)
19423 {
19424 if(!pfread(&temp.title,sizeof(char)*20,f,true))
19425 {
19426 return qe_invalid;
19427 }
19428 }
19429 else
19430 {
19431
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!pfread(&temp.title,sizeof(temp.title),f,true))
19432 {
19433 return qe_invalid;
19434 }
19435 }
19436
19437
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!p_igetl(&temp.start,f,true))
19438 {
19439 return qe_invalid;
19440 }
19441
19442
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!p_igetl(&temp.loop_start,f,true))
19443 {
19444 return qe_invalid;
19445 }
19446
19447
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!p_igetl(&temp.loop_end,f,true))
19448 {
19449 return qe_invalid;
19450 }
19451
19452
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!p_igetw(&temp.loop,f,true))
19453 {
19454 return qe_invalid;
19455 }
19456
19457
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!p_igetw(&temp.volume,f,true))
19458 {
19459 return qe_invalid;
19460 }
19461
19462
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(Header->zelda_version < 0x193)
19463 {
19464 if(!p_igetl(&dummy,f,true))
19465 {
19466 return qe_invalid;
19467 }
19468 }
19469
19470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 if(section_version >= 3)
19471 {
19472
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!pfread(&temp.flags,sizeof(temp.flags),f,true))
19473 {
19474 return qe_invalid;
19475 }
19476 90 }
19477
19478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 if(keepdata==true)
19479 {
19480 90 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19481 90 }
19482
19483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19484 {
19485 // old format - a midi is a midi
19486 if(((keepdata==true?tunes[i].data:temp.data)=read_midi(f, true))==NULL)
19487 {
19488 return qe_invalid;
19489 }
19490
19491 //yes you can do this. Isn't the ? operator awesome? :)
19492 (keepdata ? tunes[i] : temp).format = MFORMAT_MIDI;
19493 }
19494 else
19495 {
19496 // 'midi' could be midi or nes, gb, ... music
19497
2/4
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
90 if(!pfread(&(keepdata ? tunes[i] : temp).format,sizeof((keepdata ? tunes[i] : temp).format),f,true))
19498 {
19499 return qe_invalid;
19500 }
19501
19502
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 zctune *ptr = (keepdata==true)?&(tunes[i]):&temp;
19503
19504
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 switch(temp.format)
19505 {
19506 case MFORMAT_MIDI:
19507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 if((ptr->data=read_midi(f, true))==NULL)
19508 {
19509 return qe_invalid;
19510 }
19511
19512 90 break;
19513
19514 default:
19515 return qe_invalid;
19516 break;
19517 }
19518 }
19519 90 }
19520 3276 }
19521
19522 13 return 0;
19523 13 }
19524
19525 13 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header, bool keepdata)
19526 {
19527 int32_t dummy;
19528 ZCHEATS tempzcheats;
19529 13 char temp_use_cheats=1;
19530 13 memset(&tempzcheats, 0, sizeof(tempzcheats));
19531 13 word s_version = 0;
19532
19533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(Header->zelda_version > 0x192)
19534 {
19535 //section version info
19536
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_version,f,true))
19537 {
19538 return qe_invalid;
19539 }
19540
19541 13 FFCore.quest_format[vCheats] = s_version;
19542 //al_trace("Cheats version %d\n", dummy);
19543
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&dummy,f,true))
19544 {
19545 return qe_invalid;
19546 }
19547
19548 //section size
19549
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy,f,true))
19550 {
19551 return qe_invalid;
19552 }
19553
19554 //finally... section data
19555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!p_getc(&temp_use_cheats,f,true))
19556 {
19557 return qe_invalid;
19558 }
19559 13 }
19560
19561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(Header->data_flags[ZQ_CHEATS2])
19562 {
19563
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&tempzcheats.flags,f,true))
19564 {
19565 return qe_invalid;
19566 }
19567
19568
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes), f,true))
19569 {
19570 return qe_invalid;
19571 }
19572 13 }
19573
19574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata==true)
19575 {
19576 13 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19577 13 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19578 13 }
19579
19580 13 return 0;
19581 13 }
19582
19583 35 int32_t readinitdata(PACKFILE *f, zquestheader *Header, bool keepdata)
19584 {
19585 int32_t dummy;
19586 35 word s_version=0, s_cversion=0;
19587 byte padding;
19588 word tempw;
19589
19590 35 zinitdata temp_zinit;
19591
19592 // Legacy item properties (now integrated into itemdata)
19593 byte sword_hearts[4];
19594 byte beam_hearts[4];
19595 35 byte beam_percent=0;
19596 word beam_power[4];
19597 35 byte hookshot_length=99;
19598 35 byte hookshot_links=100;
19599 35 byte longshot_length=99;
19600 35 byte longshot_links=100;
19601 35 byte moving_fairy_hearts=3;
19602 35 byte moving_fairy_heart_percent=0;
19603 35 byte stationary_fairy_hearts=3;
19604 35 byte stationary_fairy_heart_percent=0;
19605 35 byte moving_fairy_magic=0;
19606 35 byte moving_fairy_magic_percent=0;
19607 35 byte stationary_fairy_magic=0;
19608 35 byte stationary_fairy_magic_percent=0;
19609 35 byte blue_potion_hearts=100;
19610 35 byte blue_potion_heart_percent=1;
19611 35 byte red_potion_hearts=100;
19612 35 byte red_potion_heart_percent=1;
19613 35 byte blue_potion_magic=100;
19614 35 byte blue_potion_magic_percent=1;
19615 35 byte red_potion_magic=100;
19616 35 byte red_potion_magic_percent=1;
19617
19618
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 22 times.
35 temp_zinit.subscreen_style=get_bit(quest_rules,qr_COOLSCROLL)?1:0;
19619
19620
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Header->zelda_version > 0x192)
19621 {
19622 //section version info
19623
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&s_version,f,true))
19624 {
19625 return qe_invalid;
19626 }
19627
19628 13 FFCore.quest_format[vInitData] = s_version;
19629
19630 //al_trace("Init data version %d\n", s_version);
19631
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&s_cversion,f,true))
19632 {
19633 return qe_invalid;
19634 }
19635
19636 //section size
19637
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetl(&dummy,f,true))
19638 {
19639 return qe_invalid;
19640 }
19641 13 }
19642
19643 /* HIGHLY UNORTHODOX UPDATING THING, by L
19644 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19645 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19646 * changing from 13 to 14.
19647 */
19648
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(keepdata && s_version < 14)
19649 fixpolsvoice=true;
19650
19651 /* End highly unorthodox updating thing */
19652
19653
4/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 2 times.
13 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19654 2 temp_zinit.jump_hero_layer_threshold=0;
19655
19656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version >= 10)
19657 {
19658 char temp;
19659
19660 //new-style items
19661
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t j=0; j<256; j++)
19662 {
19663
2/4
✓ Branch 0 taken 3328 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3328 times.
3328 if(!p_getc(&temp,f,true))
19664 return qe_invalid;
19665
19666 3328 temp_zinit.items[j] = (temp != 0);
19667 3328 }
19668 13 }
19669
19670
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
13 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19671 {
19672 char temp;
19673
19674 //finally... section data
19675
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
22 if((Header->zelda_version > 0x192)||
19676 //new only
19677 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19678 {
19679 //OLD-style items... sigh
19680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version < 10)
19681 {
19682 if(!p_getc(&temp,f,true))
19683 {
19684 return qe_invalid;
19685 }
19686
19687 temp_zinit.items[iRaft]=(temp != 0);
19688
19689 if(!p_getc(&temp,f,true))
19690 {
19691 return qe_invalid;
19692 }
19693
19694 temp_zinit.items[iLadder]=(temp != 0);
19695
19696 if(!p_getc(&temp,f,true))
19697 {
19698 return qe_invalid;
19699 }
19700
19701 temp_zinit.items[iBook]=(temp != 0);
19702
19703 if(!p_getc(&temp,f,true))
19704 {
19705 return qe_invalid;
19706 }
19707
19708 temp_zinit.items[iMKey]=(temp!=0);
19709
19710 if(!p_getc(&temp,f,true))
19711 {
19712 return qe_invalid;
19713 }
19714
19715 temp_zinit.items[iFlippers]=(temp != 0);
19716
19717 if(!p_getc(&temp,f,true))
19718 {
19719 return qe_invalid;
19720 }
19721
19722 temp_zinit.items[iBoots]=(temp!=0);
19723 }
19724 13 }
19725
19726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(s_version < 10)
19727 {
19728 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19729
19730 if(!p_getc(&tempring,f,true))
19731 {
19732 return qe_invalid;
19733 }
19734
19735 if(!p_getc(&tempsword,f,true))
19736 {
19737 return qe_invalid;
19738 }
19739
19740 if(!p_getc(&tempshield,f,true))
19741 {
19742 return qe_invalid;
19743 }
19744
19745 if(!p_getc(&tempwallet,f,true))
19746 {
19747 return qe_invalid;
19748 }
19749
19750 if(!p_getc(&tempbracelet,f,true))
19751 {
19752 return qe_invalid;
19753 }
19754
19755 if(!p_getc(&tempamulet,f,true))
19756 {
19757 return qe_invalid;
19758 }
19759
19760 if(!p_getc(&tempbow,f,true))
19761 {
19762 return qe_invalid;
19763 }
19764
19765 //old only
19766 if((Header->zelda_version == 0x192)&&(Header->build<174))
19767 {
19768 tempring=(tempring)?(1<<(tempring-1)):0;
19769 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19770 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19771 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19772 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19773 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19774 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19775 }
19776
19777 //rings start at level 2... wtf
19778 //account for this -DD
19779 tempring <<= 1;
19780 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19781 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19782 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19783 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19784 //bracelet ALSO starts at level 2 :-( -DD
19785 tempbracelet<<=1;
19786 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19787 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19788 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19789
19790 //new only
19791 if((Header->zelda_version == 0x192)&&(Header->build>173))
19792 {
19793 for(int32_t q=0; q<32; q++)
19794 {
19795 if(!p_getc(&padding,f,true))
19796 {
19797 return qe_invalid;
19798 }
19799 }
19800 }
19801
19802 char tempcandle, tempboomerang, temparrow, tempwhistle;
19803
19804 if(!p_getc(&tempcandle,f,true))
19805 {
19806 return qe_invalid;
19807 }
19808
19809 if(!p_getc(&tempboomerang,f,true))
19810 {
19811 return qe_invalid;
19812 }
19813
19814 if(!p_getc(&temparrow,f,true))
19815 {
19816 return qe_invalid;
19817 }
19818
19819 if(!p_getc(&temp,f,true))
19820 {
19821 return qe_invalid;
19822 }
19823
19824 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19825
19826 if(!p_getc(&tempwhistle,f,true))
19827 {
19828 return qe_invalid;
19829 }
19830
19831 //old only
19832 if((Header->zelda_version == 0x192)&&(Header->build<174))
19833 {
19834 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19835 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19836 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19837 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19838 }
19839
19840 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19841 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19842 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19843 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19844 //What about the potion...?
19845
19846 }
19847
19848
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 if(s_version < 29)
19849 {
19850 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19851 //to jab out my eye...
19852
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 if(!p_getc(&padding,f,true))
19853 return qe_invalid;
19854 11 temp_zinit.bombs = padding;
19855
19856
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 if(!p_getc(&padding,f,true))
19857 return qe_invalid;
19858 11 temp_zinit.super_bombs = padding;
19859 11 }
19860
19861 //Back to more OLD item code
19862
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
22 if(s_version < 10)
19863 {
19864 if((Header->zelda_version > 0x192)||
19865 //new only
19866 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19867 {
19868 if(!p_getc(&temp,f,true))
19869 {
19870 return qe_invalid;
19871 }
19872
19873 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19874
19875 if(!p_getc(&temp,f,true))
19876 {
19877 return qe_invalid;
19878 }
19879
19880 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19881
19882 if(!p_getc(&temp,f,true))
19883 {
19884 return qe_invalid;
19885 }
19886
19887 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19888
19889 if(!p_getc(&temp,f,true))
19890 {
19891 return qe_invalid;
19892 }
19893
19894 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19895
19896 if(!p_getc(&temp,f,true))
19897 {
19898 return qe_invalid;
19899 }
19900
19901 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19902
19903 if(!p_getc(&temp,f,true))
19904 {
19905 return qe_invalid;
19906 }
19907
19908 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19909
19910 if(!p_getc(&temp,f,true))
19911 {
19912 return qe_invalid;
19913 }
19914
19915 addOldStyleFamily(&temp_zinit, itemsbuf, itype_dinsfire, temp);
19916
19917 if(!p_getc(&temp,f,true))
19918 {
19919 return qe_invalid;
19920 }
19921
19922 addOldStyleFamily(&temp_zinit, itemsbuf, itype_faroreswind, temp);
19923
19924 if(!p_getc(&temp,f,true))
19925 {
19926 return qe_invalid;
19927 }
19928
19929 addOldStyleFamily(&temp_zinit, itemsbuf, itype_nayruslove, temp);
19930
19931 if(!p_getc(&temp,f,true))
19932 {
19933 return qe_invalid;
19934 }
19935
19936 if(Header->zelda_version == 0x192)
19937 {
19938 for(int32_t q=0; q<32; q++)
19939 {
19940 if(!p_getc(&padding,f,true))
19941 {
19942 return qe_invalid;
19943 }
19944 }
19945 }
19946 }
19947 }
19948
19949 //old only
19950 if((Header->zelda_version == 0x192)&&(Header->build<174))
19951 {
19952 byte equipment, items; //bit flags
19953
19954 if(!p_getc(&equipment,f,true))
19955 {
19956 return qe_invalid;
19957 }
19958
19959 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19960 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19961 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19962 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19963 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19964 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19965
19966
19967 if(!p_getc(&items,f,true))
19968 {
19969 return qe_invalid;
19970 }
19971
19972 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19973 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19974 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
19975 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
19976 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
19977 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
19978 }
19979
19980 if(!p_getc(&temp_zinit.hc,f,true))
19981 {
19982 return qe_invalid;
19983 }
19984
19985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version < 14)
19986 {
19987 byte temphp;
19988
19989 if(!p_getc(&temphp,f,true))
19990 {
19991 return qe_invalid;
19992 }
19993
19994 temp_zinit.start_heart=temphp;
19995
19996 if(!p_getc(&temphp,f,true))
19997 {
19998 return qe_invalid;
19999 }
20000
20001 temp_zinit.cont_heart=temphp;
20002 }
20003 else
20004 {
20005
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.start_heart,f,true))
20006 {
20007 return qe_invalid;
20008 }
20009
20010
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.cont_heart,f,true))
20011 {
20012 return qe_invalid;
20013 }
20014 }
20015
20016
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.hcp,f,true))
20017 {
20018 return qe_invalid;
20019 }
20020
20021
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version >= 14)
20022 {
20023
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.hcp_per_hc,f,true))
20024 {
20025 return qe_invalid;
20026 }
20027
20028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version<16) // July 2007
20029 {
20030 if(get_bit(quest_rules,qr_BRANGPICKUP+1))
20031 temp_zinit.hcp_per_hc = 0xFF;
20032
20033 //Dispose of legacy rule
20034 set_bit(quest_rules,qr_BRANGPICKUP+1, 0);
20035 }
20036 13 }
20037
20038
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(s_version < 29)
20039 {
20040
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 if(!p_getc(&padding,f,true))
20041 return qe_invalid;
20042 11 temp_zinit.max_bombs = padding;
20043 11 }
20044
20045
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.keys,f,true))
20046 {
20047 return qe_invalid;
20048 }
20049
20050
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.rupies,f,true))
20051 {
20052 return qe_invalid;
20053 }
20054
20055
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.triforce,f,true))
20056 {
20057 return qe_invalid;
20058 }
20059
20060
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20061 {
20062
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 13 times.
845 for(int32_t i=0; i<64; i++)
20063 {
20064
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 832 times.
832 if(!p_getc(&temp_zinit.map[i],f,true))
20065 {
20066 return qe_invalid;
20067 }
20068 832 }
20069
20070
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 13 times.
845 for(int32_t i=0; i<64; i++)
20071 {
20072
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 832 times.
832 if(!p_getc(&temp_zinit.compass[i],f,true))
20073 {
20074 return qe_invalid;
20075 }
20076 832 }
20077 13 }
20078 else
20079 {
20080 for(int32_t i=0; i<32; i++)
20081 {
20082 if(!p_getc(&temp_zinit.map[i],f,true))
20083 {
20084 return qe_invalid;
20085 }
20086 }
20087
20088 for(int32_t i=0; i<32; i++)
20089 {
20090 if(!p_getc(&temp_zinit.compass[i],f,true))
20091 {
20092 return qe_invalid;
20093 }
20094 }
20095 }
20096
20097
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if((Header->zelda_version > 0x192)||
20098 //new only
20099 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20100 {
20101
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20102 {
20103
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 13 times.
845 for(int32_t i=0; i<64; i++)
20104 {
20105
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 832 times.
832 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20106 {
20107 return qe_invalid;
20108 }
20109 832 }
20110 13 }
20111 else
20112 {
20113 for(int32_t i=0; i<32; i++)
20114 {
20115 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20116 {
20117 return qe_invalid;
20118 }
20119 }
20120 }
20121 13 }
20122
20123
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 208 times.
221 for(int32_t i=0; i<16; i++)
20124 {
20125
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 208 times.
208 if(!p_getc(&temp_zinit.misc[i],f,true))
20126 {
20127 return qe_invalid;
20128 }
20129 208 }
20130
20131
1/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if(s_version < 15) for(int32_t i=0; i<4; i++)
20132 {
20133 if(!p_getc(&sword_hearts[i],f,true))
20134 {
20135 return qe_invalid;
20136 }
20137 }
20138
20139
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.last_map,f,true))
20140 {
20141 return qe_invalid;
20142 }
20143
20144
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.last_screen,f,true))
20145 {
20146 return qe_invalid;
20147 }
20148
20149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version < 14)
20150 {
20151 byte tempmp;
20152
20153 if(!p_getc(&tempmp,f,true))
20154 {
20155 return qe_invalid;
20156 }
20157
20158 temp_zinit.max_magic=tempmp;
20159
20160 if(!p_getc(&tempmp,f,true))
20161 {
20162 return qe_invalid;
20163 }
20164
20165 temp_zinit.magic=tempmp;
20166 }
20167 else
20168 {
20169
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.max_magic,f,true))
20170 {
20171 return qe_invalid;
20172 }
20173
20174
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.magic,f,true))
20175 {
20176 return qe_invalid;
20177 }
20178 }
20179
20180
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version < 15)
20181 {
20182 if(s_version < 12)
20183 {
20184 temp_zinit.max_magic*=32;
20185 temp_zinit.magic*=32;
20186 }
20187
20188 for(int32_t i=0; i<4; i++)
20189 {
20190 if(!p_getc(&beam_hearts[i],f,true))
20191 {
20192 return qe_invalid;
20193 }
20194 }
20195
20196 if(!p_getc(&beam_percent,f,true))
20197 {
20198 return qe_invalid;
20199 }
20200 }
20201 else
20202 {
20203
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.bomb_ratio,f,true))
20204 {
20205 return qe_invalid;
20206 }
20207 }
20208
20209
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version < 15)
20210 {
20211 byte tempbp;
20212
20213 for(int32_t i=0; i<4; i++)
20214 {
20215 if(!(s_version < 14 ? p_getc(&tempbp,f,true) : p_igetw(&tempbp,f,true)))
20216 {
20217 return qe_invalid;
20218 }
20219
20220 beam_power[i]=tempbp;
20221 }
20222
20223 if(!p_getc(&hookshot_links,f,true))
20224 {
20225 return qe_invalid;
20226 }
20227
20228 if(s_version>6)
20229 {
20230 if(!p_getc(&hookshot_length,f,true))
20231 {
20232 return qe_invalid;
20233 }
20234
20235 if(!p_getc(&longshot_links,f,true))
20236 {
20237 return qe_invalid;
20238 }
20239
20240 if(!p_getc(&longshot_length,f,true))
20241 {
20242 return qe_invalid;
20243 }
20244 }
20245 }
20246
20247
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.msg_more_x,f,true))
20248 {
20249 return qe_invalid;
20250 }
20251
20252
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.msg_more_y,f,true))
20253 {
20254 return qe_invalid;
20255 }
20256
20257
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.subscreen,f,true))
20258 {
20259 return qe_invalid;
20260 }
20261
20262 //old only
20263
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if((Header->zelda_version == 0x192)&&(Header->build<174))
20264 {
20265 for(int32_t i=0; i<32; i++)
20266 {
20267 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20268 {
20269 return qe_invalid;
20270 }
20271 }
20272 }
20273
20274
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20275 {
20276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version <= 10)
20277 {
20278 byte tempbyte;
20279
20280 if(!p_getc(&tempbyte,f,true))
20281 {
20282 return qe_invalid;
20283 }
20284
20285 temp_zinit.start_dmap = (word)tempbyte;
20286 }
20287 else
20288 {
20289
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.start_dmap,f,true))
20290 {
20291 return qe_invalid;
20292 }
20293 }
20294
20295
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.heroAnimationStyle,f,true))
20296 {
20297 return qe_invalid;
20298 }
20299 13 }
20300
20301
3/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 2 times.
13 if(s_version>1 && s_version < 29)
20302 {
20303
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 if(!p_getc(&padding,f,true))
20304 return qe_invalid;
20305 11 temp_zinit.arrows = padding;
20306
20307
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 if(!p_getc(&padding,f,true))
20308 return qe_invalid;
20309 11 temp_zinit.max_arrows = padding;
20310 11 }
20311
20312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version>2)
20313 {
20314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version <= 10)
20315 {
20316 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20317 {
20318 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20319 {
20320 return qe_invalid;
20321 }
20322 }
20323 }
20324 else
20325 {
20326
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 13 times.
6669 for(int32_t i=0; i<MAXLEVELS; i++)
20327 {
20328
2/4
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6656 times.
✗ Branch 3 not taken.
6656 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20329 {
20330 return qe_invalid;
20331 }
20332 6656 }
20333 }
20334 13 }
20335
20336
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version>3)
20337 {
20338
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.ss_grid_x,f,true))
20339 {
20340 return qe_invalid;
20341 }
20342
20343
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.ss_grid_y,f,true))
20344 {
20345 return qe_invalid;
20346 }
20347
20348
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.ss_grid_xofs,f,true))
20349 {
20350 return qe_invalid;
20351 }
20352
20353
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.ss_grid_yofs,f,true))
20354 {
20355 return qe_invalid;
20356 }
20357
20358
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.ss_grid_color,f,true))
20359 {
20360 return qe_invalid;
20361 }
20362
20363
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f,true))
20364 {
20365 return qe_invalid;
20366 }
20367
20368
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f,true))
20369 {
20370 return qe_invalid;
20371 }
20372
20373
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.ss_flags,f,true))
20374 {
20375 return qe_invalid;
20376 }
20377
20378
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20379
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20380 13 }
20381
20382
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(s_version>4 && s_version<15)
20383 {
20384 if(!p_getc(&moving_fairy_hearts,f,true))
20385 {
20386 return qe_invalid;
20387 }
20388
20389 if(!p_getc(&moving_fairy_heart_percent,f,true))
20390 {
20391 return qe_invalid;
20392 }
20393 }
20394
20395
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(s_version>5 && s_version < 10)
20396 {
20397 if(!p_getc(&temp,f,true))
20398 {
20399 return qe_invalid;
20400 }
20401
20402 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20403 }
20404
20405
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(s_version>6 && s_version<15)
20406 {
20407 if(!p_getc(&stationary_fairy_hearts,f,true))
20408 {
20409 return qe_invalid;
20410 }
20411
20412 if(!p_getc(&stationary_fairy_heart_percent,f,true))
20413 {
20414 return qe_invalid;
20415 }
20416
20417 if(!p_getc(&moving_fairy_magic,f,true))
20418 {
20419 return qe_invalid;
20420 }
20421
20422 if(!p_getc(&moving_fairy_magic_percent,f,true))
20423 {
20424 return qe_invalid;
20425 }
20426
20427 if(!p_getc(&stationary_fairy_magic,f,true))
20428 {
20429 return qe_invalid;
20430 }
20431
20432 if(!p_getc(&stationary_fairy_magic_percent,f,true))
20433 {
20434 return qe_invalid;
20435 }
20436
20437 if(!p_getc(&blue_potion_hearts,f,true))
20438 {
20439 return qe_invalid;
20440 }
20441
20442 if(!p_getc(&blue_potion_heart_percent,f,true))
20443 {
20444 return qe_invalid;
20445 }
20446
20447 if(!p_getc(&red_potion_hearts,f,true))
20448 {
20449 return qe_invalid;
20450 }
20451
20452 if(!p_getc(&red_potion_heart_percent,f,true))
20453 {
20454 return qe_invalid;
20455 }
20456
20457 if(!p_getc(&blue_potion_magic,f,true))
20458 {
20459 return qe_invalid;
20460 }
20461
20462 if(!p_getc(&blue_potion_magic_percent,f,true))
20463 {
20464 return qe_invalid;
20465 }
20466
20467 if(!p_getc(&red_potion_magic,f,true))
20468 {
20469 return qe_invalid;
20470 }
20471
20472 if(!p_getc(&red_potion_magic_percent,f,true))
20473 {
20474 return qe_invalid;
20475 }
20476 }
20477
20478
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version>6)
20479 {
20480
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.subscreen_style,f,true))
20481 {
20482 return qe_invalid;
20483 }
20484 13 }
20485
20486
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version>7)
20487 {
20488
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.usecustomsfx,f,true))
20489 {
20490 return qe_invalid;
20491 }
20492 13 }
20493
20494
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version>8)
20495 {
20496
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.max_rupees,f,true))
20497 {
20498 return qe_invalid;
20499 }
20500
20501
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.max_keys,f,true))
20502 {
20503 return qe_invalid;
20504 }
20505 13 }
20506
20507
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version>16)
20508 {
20509
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.gravity,f,true))
20510 {
20511 return qe_invalid;
20512 }
20513
20514
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&temp_zinit.terminalv,f,true))
20515 {
20516 return qe_invalid;
20517 }
20518
20519
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.msg_speed,f,true))
20520 {
20521 return qe_invalid;
20522 }
20523
20524
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.transition_type,f,true))
20525 {
20526 return qe_invalid;
20527 }
20528
20529
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f,true))
20530 {
20531 return qe_invalid;
20532 }
20533 13 }
20534
20535
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version>17)
20536 {
20537
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_getc(&temp_zinit.msg_more_is_offset,f,true))
20538 {
20539 return qe_invalid;
20540 }
20541 13 }
20542
20543 //expaned init data for larger values in 2.55
20544
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20545 {
20546
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetw(&temp_zinit.bombs,f,true))
20547 {
20548 return qe_invalid;
20549 }
20550
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetw(&temp_zinit.super_bombs,f,true))
20551 {
20552 return qe_invalid;
20553 }
20554
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetw(&temp_zinit.max_bombs,f,true))
20555 {
20556 return qe_invalid;
20557 }
20558
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetw(&temp_zinit.max_sbombs,f,true))
20559 {
20560 return qe_invalid;
20561 }
20562
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetw(&temp_zinit.arrows,f,true))
20563 {
20564 return qe_invalid;
20565 }
20566
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetw(&temp_zinit.max_arrows,f,true))
20567 {
20568 return qe_invalid;
20569 }
20570
20571 2 }
20572
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if ( s_version >= 20 )
20573 {
20574
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetw(&temp_zinit.heroStep,f,true))
20575 {
20576 return qe_invalid;
20577 }
20578 2 }
20579 else
20580 {
20581 11 temp_zinit.heroStep = 150; //1.5 pixels per frame
20582 }
20583
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if ( s_version >= 21 )
20584 {
20585
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetw(&temp_zinit.subscrSpeed,f,true))
20586 {
20587 return qe_invalid;
20588 }
20589 2 }
20590 else
20591 {
20592 11 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20593 }
20594 //old only
20595
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13 if((Header->zelda_version == 0x192)&&(Header->build<174))
20596 {
20597 byte items2;
20598
20599 if(!p_getc(&items2,f,true))
20600 {
20601 return qe_invalid;
20602 }
20603
20604 temp_zinit.items[iDinsFire]=(get_bit(&items2, idI_DFIRE)!=0);
20605 temp_zinit.items[iFaroresWind]=(get_bit(&items2, idI_FWIND)!=0);
20606 temp_zinit.items[iNayrusLove]=(get_bit(&items2, idI_NLOVE)!=0);
20607 }
20608
20609
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Header->zelda_version < 0x193)
20610 {
20611 for(int32_t q=0; q<96; q++)
20612 {
20613 if(!p_getc(&padding,f,true))
20614 {
20615 return qe_invalid;
20616 }
20617 }
20618
20619 //new only
20620 if((Header->zelda_version == 0x192)&&(Header->build>173))
20621 {
20622 if(!p_getc(&padding,f,true))
20623 {
20624 return qe_invalid;
20625 }
20626
20627 if(!p_getc(&padding,f,true))
20628 {
20629 return qe_invalid;
20630 }
20631 }
20632 }
20633 13 }
20634
20635
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20636 {
20637 //temp_zinit.shield=i_smallshield;
20638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20639
20640 if(sshieldid != -1)
20641 temp_zinit.items[sshieldid] = true;
20642 }
20643
20644
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20645 {
20646 temp_zinit.hc=3;
20647 temp_zinit.start_heart=3;
20648 temp_zinit.cont_heart=3;
20649 temp_zinit.max_bombs=8;
20650 }
20651
20652
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20653 {
20654 sword_hearts[0]=0;
20655 sword_hearts[1]=5;
20656 sword_hearts[2]=12;
20657 sword_hearts[3]=21;
20658 }
20659
20660
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20661 {
20662 temp_zinit.last_map=0;
20663 temp_zinit.last_screen=0;
20664 }
20665
20666
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20667 {
20668 temp_zinit.max_magic=0;
20669 temp_zinit.magic=0;
20670 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20671 }
20672
20673
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20674 {
20675
20676 for(int32_t x=0; x<4; x++)
20677 {
20678 beam_hearts[x]=100;
20679 }
20680
20681 for(int32_t i=0; i<idBP_MAX; i++)
20682 {
20683 set_bit(&beam_percent,i,!get_bit(quest_rules,qr_LENSHINTS+i));
20684 set_bit(quest_rules,qr_LENSHINTS+i,0);
20685 }
20686
20687 for(int32_t x=0; x<4; x++)
20688 {
20689 beam_power[x]=get_bit(quest_rules,qr_HIDECARRIEDITEMS)?50:100;
20690 }
20691
20692 set_bit(quest_rules,qr_HIDECARRIEDITEMS,0);
20693 hookshot_links=100;
20694 temp_zinit.msg_more_x=224;
20695 temp_zinit.msg_more_y=64;
20696 }
20697
20698 // Okay, let's put these legacy values into itemsbuf.
20699
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(s_version < 15)
20700 for(int32_t i=0; i<MAXITEMS; i++)
20701 {
20702 switch(i)
20703 {
20704 case iFairyStill:
20705 itemsbuf[i].misc1 = stationary_fairy_hearts;
20706 itemsbuf[i].misc2 = stationary_fairy_magic;
20707 itemsbuf[i].misc3 = 0;
20708 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20709 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20710 break;
20711
20712 case iFairyMoving:
20713 itemsbuf[i].misc1 = moving_fairy_hearts;
20714 itemsbuf[i].misc2 = moving_fairy_magic;
20715 itemsbuf[i].misc3 = 50;
20716 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20717 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20718 break;
20719
20720 case iRPotion:
20721 itemsbuf[i].misc1 = red_potion_hearts;
20722 itemsbuf[i].misc2 = red_potion_magic;
20723 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20724 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20725 break;
20726
20727 case iBPotion:
20728 itemsbuf[i].misc1 = blue_potion_hearts;
20729 itemsbuf[i].misc2 = blue_potion_magic;
20730 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20731 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20732 break;
20733
20734 case iSword:
20735 itemsbuf[i].pickup_hearts = sword_hearts[0];
20736 itemsbuf[i].misc1 = beam_hearts[0];
20737 itemsbuf[i].misc2 = beam_power[0];
20738 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20739 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20740 break;
20741
20742 case iWSword:
20743 itemsbuf[i].pickup_hearts = sword_hearts[1];
20744 itemsbuf[i].misc1 = beam_hearts[1];
20745 itemsbuf[i].misc2 = beam_power[1];
20746 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20747 break;
20748
20749 case iMSword:
20750 itemsbuf[i].pickup_hearts = sword_hearts[2];
20751 itemsbuf[i].misc1 = beam_hearts[2];
20752 itemsbuf[i].misc2 = beam_power[2];
20753 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20754 break;
20755
20756 case iXSword:
20757 itemsbuf[i].pickup_hearts = sword_hearts[3];
20758 itemsbuf[i].misc1 = beam_hearts[3];
20759 itemsbuf[i].misc2 = beam_power[3];
20760 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20761 break;
20762
20763 case iHookshot:
20764 itemsbuf[i].misc1 = hookshot_length;
20765 itemsbuf[i].misc2 = hookshot_links;
20766 break;
20767
20768 case iLongshot:
20769 itemsbuf[i].misc1 = longshot_length;
20770 itemsbuf[i].misc2 = longshot_links;
20771 break;
20772 }
20773 }
20774
20775
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20776 {
20777 //was new subscreen rule
20778 temp_zinit.subscreen=get_bit(quest_rules,qr_FREEFORM)?1:0;
20779 set_bit(quest_rules,qr_FREEFORM,0);
20780 }
20781
20782
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20783 {
20784 temp_zinit.start_dmap=0;
20785 }
20786
20787
2/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20788 {
20789 temp_zinit.heroAnimationStyle=get_bit(quest_rules,qr_BSZELDA)?1:0;
20790 }
20791
20792
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20793 {
20794 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20795 temp_zinit.max_rupees=999;
20796 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20797 }
20798
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20799 {
20800 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20801 temp_zinit.max_bombs = 8;
20802 }
20803 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20804 //time to ensure that we port all new values properly:
20805
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(Header->zelda_version < 0x250)
20806 {
20807 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20808 }
20809
20810
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version > 21)
20811 {
20812
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&temp_zinit.hp_per_heart,f,true))
20813 {
20814 return qe_invalid;
20815 }
20816
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&temp_zinit.magic_per_block,f,true))
20817 {
20818 return qe_invalid;
20819 }
20820
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&temp_zinit.hero_damage_multiplier,f,true))
20821 {
20822 return qe_invalid;
20823 }
20824
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&temp_zinit.ene_damage_multiplier,f,true))
20825 {
20826 return qe_invalid;
20827 }
20828 2 }
20829 else
20830 {
20831 11 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20832 11 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20833 11 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20834 11 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20835 }
20836
20837
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version > 22)
20838 {
20839
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 2 times.
52 for(int32_t q = 0; q < 25; ++q)
20840 {
20841
2/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
50 if(!p_igetw(&temp_zinit.scrcnt[q],f,true))
20842 {
20843 return qe_invalid;
20844 }
20845 50 }
20846
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 2 times.
52 for(int32_t q = 0; q < 25; ++q)
20847 {
20848
2/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50 times.
50 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f,true))
20849 {
20850 return qe_invalid;
20851 }
20852 50 }
20853 2 }
20854 else
20855 {
20856
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 11 times.
286 for(int32_t q = 0; q < 25; ++q)
20857 {
20858 275 temp_zinit.scrcnt[q] = 0;
20859 275 temp_zinit.scrmaxcnt[q] = 0;
20860 275 }
20861 }
20862
20863
20864
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version > 23)
20865 {
20866
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&temp_zinit.dither_type,f,true))
20867 {
20868 return qe_invalid;
20869 }
20870
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&temp_zinit.dither_arg,f,true))
20871 {
20872 return qe_invalid;
20873 }
20874
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&temp_zinit.dither_percent,f,true))
20875 {
20876 return qe_invalid;
20877 }
20878
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&temp_zinit.def_lightrad,f,true))
20879 {
20880 return qe_invalid;
20881 }
20882
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&temp_zinit.transdark_percent,f,true))
20883 {
20884 return qe_invalid;
20885 }
20886 2 }
20887 else
20888 {
20889 11 temp_zinit.dither_type = 0;
20890 11 temp_zinit.dither_arg = 0;
20891 11 temp_zinit.dither_percent = 20;
20892 11 temp_zinit.def_lightrad = 24;
20893 11 temp_zinit.transdark_percent = 0;
20894 }
20895
20896
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version > 24)
20897 {
20898
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&temp_zinit.darkcol,f,true))
20899 {
20900 return qe_invalid;
20901 }
20902 2 }
20903 else
20904 {
20905 11 temp_zinit.darkcol = BLACK;
20906 }
20907
20908
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version > 25)
20909 {
20910
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetl(&temp_zinit.gravity2,f,true))
20911 {
20912 return qe_invalid;
20913 }
20914
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetl(&temp_zinit.swimgravity,f,true))
20915 {
20916 return qe_invalid;
20917 }
20918 2 }
20919 else
20920 {
20921 11 temp_zinit.gravity2 = temp_zinit.gravity*100;
20922 11 temp_zinit.swimgravity = 5;
20923 }
20924
20925
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version > 26)
20926 {
20927
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f,true))
20928 {
20929 return qe_invalid;
20930 }
20931
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f,true))
20932 {
20933 return qe_invalid;
20934 }
20935
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f,true))
20936 {
20937 return qe_invalid;
20938 }
20939 2 }
20940 else
20941 {
20942 11 temp_zinit.heroSideswimUpStep = 150;
20943 11 temp_zinit.heroSideswimSideStep = 100;
20944 11 temp_zinit.heroSideswimDownStep = 75;
20945 }
20946
20947
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version > 27)
20948 {
20949
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetl(&temp_zinit.exitWaterJump,f,true))
20950 {
20951 return qe_invalid;
20952 }
20953 2 }
20954 else
20955 {
20956 11 temp_zinit.exitWaterJump = 0;
20957 }
20958
20959
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version > 29)
20960 {
20961
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_igetl(&temp_zinit.bunny_ltm,f,true))
20962 {
20963 return qe_invalid;
20964 }
20965 2 }
20966 else
20967 {
20968 11 temp_zinit.bunny_ltm = 0;
20969 }
20970
20971
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version > 30)
20972 {
20973
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&temp_zinit.switchhookstyle,f,true))
20974 {
20975 return qe_invalid;
20976 }
20977 2 }
20978 else
20979 {
20980 11 temp_zinit.switchhookstyle = 1;
20981 }
20982
20983
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11 times.
13 if(s_version > 31)
20984 {
20985
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(!p_getc(&temp_zinit.magicdrainrate,f,true))
20986 {
20987 return qe_invalid;
20988 }
20989 2 }
20990 else
20991 {
20992
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
20993
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20994 }
20995
20996
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 temp_zinit.clear_genscript();
20997
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if(s_version > 32)
20998 {
20999 1 word numgenscript = 0;
21000
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_igetw(&numgenscript,f,true))
21001 return qe_invalid;
21002
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 for(auto q = 1; q < numgenscript; ++q)
21003 {
21004
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getc(&padding,f,true))
21005 return qe_invalid;
21006
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!(padding&2))
21007 continue;
21008 1 temp_zinit.gen_doscript[q] = padding&1;
21009
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetw(&temp_zinit.gen_exitState[q],f,true))
21010 return qe_invalid;
21011
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_igetw(&temp_zinit.gen_reloadState[q],f,true))
21012 return qe_invalid;
21013
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 for(auto p = 0; p < 8; ++p)
21014
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(!p_igetl(&temp_zinit.gen_initd[q][p],f,true))
21015 return qe_invalid;
21016
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_dataSize[q],f,true))
21017 return qe_invalid;
21018
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f,true))
21019 return qe_invalid;
21020
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_eventstate[q],f,true))
21021 return qe_invalid;
21022 1 }
21023 1 }
21024
21025
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(keepdata==true)
21026 {
21027
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 zinit = temp_zinit;
21028
21029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(zinit.heroAnimationStyle==las_zelda3slow)
21030 {
21031 hero_animation_speed=2;
21032 }
21033 else
21034 {
21035 13 hero_animation_speed=1;
21036 }
21037 13 }
21038
21039 13 return 0;
21040 57 }
21041
21042 /*
21043 void setupitemdropsets()
21044 {
21045 for(int32_t i=0; i<isMAX; i++)
21046 {
21047 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21048 }
21049 }
21050 */
21051
21052 13 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build, bool keepdata)
21053 {
21054 13 build=build; // here to prevent compiler warnings
21055 dword dummy_dword;
21056 13 word item_drop_sets_to_read=0;
21057 item_drop_object tempitemdrop;
21058 13 word s_version=0, s_cversion=0;
21059
21060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(keepdata)
21061 {
21062
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 13 times.
3341 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21063 {
21064 3328 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21065 3328 }
21066 13 }
21067
21068
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(version > 0x192)
21069 {
21070 13 item_drop_sets_to_read=0;
21071
21072 //section version info
21073
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_version,f,true))
21074 {
21075 return qe_invalid;
21076 }
21077
21078 13 FFCore.quest_format[vItemDropsets] = s_version;
21079
21080 //al_trace("Item drop sets version %d\n", s_version);
21081
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_cversion,f,true))
21082 {
21083 return qe_invalid;
21084 }
21085
21086 //section size
21087
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy_dword,f,true))
21088 {
21089 return qe_invalid;
21090 }
21091
21092 //finally... section data
21093
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&item_drop_sets_to_read,f,true))
21094 {
21095 return qe_invalid;
21096 }
21097 13 }
21098 else
21099 {
21100 if(keepdata==true)
21101 {
21102 init_item_drop_sets();
21103 }
21104 }
21105
21106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(s_version>=1)
21107 {
21108
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 13 times.
213 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21109 {
21110
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f,true))
21111 {
21112 return qe_invalid;
21113 }
21114
21115
2/2
✓ Branch 0 taken 2000 times.
✓ Branch 1 taken 200 times.
2200 for(int32_t j=0; j<10; ++j)
21116 {
21117
1/2
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
2000 if(!p_igetw(&tempitemdrop.item[j],f,true))
21118 {
21119 return qe_invalid;
21120 }
21121 2000 }
21122
21123
2/2
✓ Branch 0 taken 2200 times.
✓ Branch 1 taken 200 times.
2400 for(int32_t j=0; j<11; ++j)
21124 {
21125
1/2
✓ Branch 0 taken 2200 times.
✗ Branch 1 not taken.
2200 if(!p_igetw(&tempitemdrop.chance[j],f,true))
21126 {
21127 return qe_invalid;
21128 }
21129 2200 }
21130
21131 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21132 // overrides the quest's set #12.
21133
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
200 if(s_version<2 && i==12)
21134 continue;
21135
21136 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21137
1/4
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
200 if(s_version<2) for(int32_t j=0; j<10; ++j)
21138 {
21139 int32_t it = tempitemdrop.item[j];
21140
21141 if((itemsbuf[it].family == itype_rupee
21142 && ((itemsbuf[it].amount)&0xFFF) == 10)
21143 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21144 {
21145 tempitemdrop.chance[j+1]=0;
21146 }
21147 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21148 {
21149 tempitemdrop.chance[j+1]=0;
21150 }
21151
21152 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21153 if(itemsbuf[it].family == itype_misc)
21154 {
21155 // If a non-gameplay item was selected, then item drop was aborted.
21156 // Reflect this by increasing the 'Nothing' chance accordingly.
21157 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21158 tempitemdrop.chance[j+1]=0;
21159 }
21160 }
21161
21162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(keepdata)
21163 {
21164 200 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21165 200 }
21166 200 }
21167 13 }
21168
21169 13 return 0;
21170 13 }
21171
21172 13 int32_t readfavorites(PACKFILE *f, int32_t, word, bool keepdata)
21173 {
21174 int32_t temp_num;
21175 dword dummy_dword;
21176 word num_favorite_combos;
21177 word num_favorite_combo_aliases;
21178 13 word s_version=0, s_cversion=0;
21179
21180 //section version info
21181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!p_igetw(&s_version,f,true))
21182 {
21183 return qe_invalid;
21184 }
21185
21186 13 FFCore.quest_format[vFavourites] = s_version;
21187
21188
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&s_cversion,f,true))
21189 {
21190 return qe_invalid;
21191 }
21192
21193 //section size
21194
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetl(&dummy_dword,f,true))
21195 {
21196 return qe_invalid;
21197 }
21198
21199 //finally... section data
21200
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&num_favorite_combos,f,true))
21201 {
21202 return qe_invalid;
21203 }
21204
21205
2/2
✓ Branch 0 taken 1300 times.
✓ Branch 1 taken 13 times.
1313 for(int32_t i=0; i<num_favorite_combos; i++)
21206 {
21207
1/2
✓ Branch 0 taken 1300 times.
✗ Branch 1 not taken.
1300 if(!p_igetl(&temp_num,f,true))
21208 {
21209 return qe_invalid;
21210 }
21211
21212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1300 times.
1300 if(keepdata)
21213 {
21214 1300 favorite_combos[i]=temp_num;
21215 1300 }
21216 1300 }
21217
21218
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&num_favorite_combo_aliases,f,true))
21219 {
21220 return qe_invalid;
21221 }
21222
21223
2/2
✓ Branch 0 taken 1300 times.
✓ Branch 1 taken 13 times.
1313 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21224 {
21225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1300 times.
1300 if(!p_igetl(&temp_num,f,true))
21226 {
21227 return qe_invalid;
21228 }
21229
21230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1300 times.
1300 if(keepdata)
21231 {
21232 1300 favorite_comboaliases[i]=temp_num;
21233 1300 }
21234 1300 }
21235
21236 13 return 0;
21237 13 }
21238
21239 /*
21240 switch (ret) {
21241 case 0:
21242 break;
21243
21244 case qe_invalid:
21245 goto invalid;
21246 break;
21247 default:
21248 pack_fclose(f);
21249 if(!oldquest)
21250 delete_file(tmpfilename);
21251 return ret;
21252 break;
21253 }
21254 */
21255
21256 const char *skip_text[skip_max]=
21257 {
21258 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21259 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21260 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21261 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21262 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21263 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21264 "skip_favorites"
21265 };
21266
21267
21268 void port250QuestRules(){
21269
21270 portCandleRules(); //Candle
21271 portBombRules();
21272
21273 }
21274
21275 void portCandleRules()
21276 {
21277 bool hurtshero = get_bit(quest_rules,qr_FIREPROOFHERO);
21278 //itemdata itemsbuf;
21279 for ( int32_t q = 0; q < MAXITEMS; q++ )
21280 {
21281 if ( itemsbuf[q].family == itype_candle )
21282 {
21283 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21284 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21285 }
21286 }
21287 }
21288
21289 void portBombRules()
21290 {
21291 bool hurtshero = get_bit(quest_rules,qr_OUCHBOMBS);
21292 //itemdata itemsbuf;
21293 for ( int32_t q = 0; q < MAXITEMS; q++ )
21294 {
21295 if ( itemsbuf[q].family == itype_bomb )
21296 {
21297 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21298 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21299 }
21300 }
21301
21302 }
21303
21304 //Internal function for loadquest wrapper
21305 13 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool compressed, bool encrypted, bool keepall, const byte *skip_flags, byte printmetadata)
21306 {
21307 13 DMapEditorLastMaptileUsed = 0;
21308 13 combosread=false;
21309 13 mapsread=false;
21310 13 fixffcs=false;
21311
21312
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if(get_debug()&&(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
21313 {
21314 keepall=false;
21315 jwin_alert("Load Quest","Data retention disabled.",NULL,NULL,"OK",NULL,13,27,lfont);
21316 }
21317
21318 // show_progress=true;
21319 char tmpfilename[L_tmpnam];
21320 13 temp_name(tmpfilename);
21321 // char percent_done[30];
21322 13 bool catchup=false;
21323 byte tempbyte;
21324 13 word old_map_count=map_count;
21325
21326 13 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21327 13 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21328 13 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21329
21330
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(keepall==false||get_bit(skip_flags, skip_rules))
21331 {
21332 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21333 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21334 }
21335
21336 13 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21337 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21338
21339
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(keepall==false||get_bit(skip_flags, skip_midis))
21340 {
21341 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21342 }
21343
21344
21345
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(keepall&&!get_bit(skip_flags, skip_ffscript))
21346 {
21347 13 zScript.clear();
21348 13 globalmap.clear();
21349 13 genericmap.clear();
21350 13 ffcmap.clear();
21351 13 itemmap.clear();
21352 13 npcmap.clear();
21353 13 ewpnmap.clear();
21354 13 lwpnmap.clear();
21355 13 playermap.clear();
21356 13 dmapmap.clear();
21357 13 screenmap.clear();
21358 13 itemspritemap.clear();
21359 13 comboscriptmap.clear();
21360
21361
2/2
✓ Branch 0 taken 6643 times.
✓ Branch 1 taken 13 times.
6656 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21362 {
21363 6643 ffcmap[i].clear();
21364 6643 }
21365
21366 13 globalmap[0].slotname = "Slot 1:";
21367 13 globalmap[0].scriptname = "~Init";
21368 13 globalmap[0].update();
21369
21370
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 13 times.
104 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21371 {
21372 91 globalmap[i].clear();
21373 91 }
21374
21375
2/2
✓ Branch 0 taken 3315 times.
✓ Branch 1 taken 13 times.
3328 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21376 {
21377 3315 itemmap[i].clear();
21378 3315 }
21379
21380 //new script types -- prevent carrying over to a quest that you load after reading them
21381 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21382
2/2
✓ Branch 0 taken 3315 times.
✓ Branch 1 taken 13 times.
3328 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21383 {
21384 3315 npcmap[i].clear();
21385 3315 }
21386
2/2
✓ Branch 0 taken 3315 times.
✓ Branch 1 taken 13 times.
3328 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21387 {
21388 3315 lwpnmap[i].clear();
21389 3315 }
21390
2/2
✓ Branch 0 taken 3315 times.
✓ Branch 1 taken 13 times.
3328 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21391 {
21392 3315 ewpnmap[i].clear();
21393 3315 }
21394
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 13 times.
65 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21395 {
21396 52 playermap[i].clear();
21397 52 }
21398
2/2
✓ Branch 0 taken 3315 times.
✓ Branch 1 taken 13 times.
3328 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21399 {
21400 3315 dmapmap[i].clear();
21401 3315 }
21402
2/2
✓ Branch 0 taken 3315 times.
✓ Branch 1 taken 13 times.
3328 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21403 {
21404 3315 screenmap[i].clear();
21405 3315 }
21406
2/2
✓ Branch 0 taken 3315 times.
✓ Branch 1 taken 13 times.
3328 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21407 {
21408 3315 itemspritemap[i].clear();
21409 3315 }
21410
2/2
✓ Branch 0 taken 6643 times.
✓ Branch 1 taken 13 times.
6656 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21411 {
21412 6643 comboscriptmap[i].clear();
21413 6643 }
21414
2/2
✓ Branch 0 taken 6643 times.
✓ Branch 1 taken 13 times.
6656 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21415 {
21416 6643 genericmap[i].clear();
21417 6643 }
21418
21419 13 reset_scripts();
21420 13 }
21421
21422 zquestheader tempheader;
21423 13 memset(&tempheader, 0, sizeof(zquestheader));
21424 13 zinfo tempzi;
21425 13 tempzi.clear();
21426 13 load_tmp_zi = &tempzi;
21427
21428 // oldquest flag is set when an unencrypted qst file is suspected.
21429 13 bool oldquest = false;
21430 13 int32_t open_error=0;
21431 char deletefilename[1024];
21432 13 PACKFILE *f=open_quest_file(&open_error, filename, deletefilename, compressed, encrypted, show_progress);
21433
21434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!f)
21435 return open_error;
21436 char zinfofilename[2048];
21437 13 replace_extension(zinfofilename, filename, "zinfo", 2047);
21438 13 int32_t ret=0;
21439
21440 //header
21441 13 box_out("Reading Header...");
21442 13 ret=readheader(f, &tempheader, true, printmetadata);
21443
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21444 13 box_out("okay.");
21445 13 box_eol();
21446
21447
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2 times.
13 if(read_zinfo)
21448 {
21449 2 box_out("Reading ZInfo - ");
21450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 box_out(read_ext_zinfo ? "External..." : "Internal...");
21451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(read_ext_zinfo)
21452 {
21453 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21454 ret=readzinfo(inf, tempzi, tempheader);
21455 if(inf) pack_fclose(inf);
21456 checkstatus(ret);
21457 }
21458 else
21459 {
21460 2 ret=readzinfo(f, tempzi, tempheader);
21461
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
21462 }
21463 2 box_out("okay.");
21464 2 box_eol();
21465 2 }
21466
21467
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(tempheader.zelda_version>=0x193)
21468 {
21469 dword section_id;
21470
21471 //section id
21472
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_mgetl(&section_id,f,true))
21473 {
21474 return qe_invalid;
21475 }
21476
21477
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 13 times.
325 while(!pack_feof(f))
21478 {
21479
24/25
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 13 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 13 times.
✓ Branch 8 taken 13 times.
✓ Branch 9 taken 13 times.
✓ Branch 10 taken 13 times.
✓ Branch 11 taken 13 times.
✓ Branch 12 taken 13 times.
✓ Branch 13 taken 13 times.
✓ Branch 14 taken 13 times.
✓ Branch 15 taken 13 times.
✓ Branch 16 taken 13 times.
✓ Branch 17 taken 13 times.
✓ Branch 18 taken 13 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 13 times.
✓ Branch 21 taken 13 times.
✓ Branch 22 taken 13 times.
✓ Branch 23 taken 13 times.
✓ Branch 24 taken 13 times.
312 switch(section_id)
21480 {
21481 case ID_RULES:
21482
21483 //rules
21484
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21485 {
21486 box_out("found.");
21487 box_eol();
21488 catchup=false;
21489 }
21490
21491 13 box_out("Reading Rules...");
21492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21493
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21494 13 box_out("okay.");
21495 13 box_eol();
21496 13 break;
21497
21498 case ID_STRINGS:
21499
21500 //strings
21501
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21502 {
21503 box_out("found.");
21504 box_eol();
21505 catchup=false;
21506 }
21507
21508 13 box_out("Reading Strings...");
21509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21510
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21511 13 box_out("okay.");
21512 13 box_eol();
21513 13 break;
21514
21515 case ID_MISC:
21516
21517 //misc data
21518
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21519 {
21520 box_out("found.");
21521 box_eol();
21522 catchup=false;
21523 }
21524
21525 13 box_out("Reading Misc. Data...");
21526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21527
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21528 13 box_out("okay.");
21529 13 box_eol();
21530 13 break;
21531
21532 case ID_TILES:
21533
21534 //tiles
21535
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21536 {
21537 box_out("found.");
21538 box_eol();
21539 catchup=false;
21540 }
21541
21542 13 box_out("Reading Tiles...");
21543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
21544
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21545 13 box_out("okay.");
21546 13 box_eol();
21547 13 break;
21548
21549 case ID_COMBOS:
21550
21551 //combos
21552
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21553 {
21554 box_out("found.");
21555 box_eol();
21556 catchup=false;
21557 }
21558
21559 13 box_out("Reading Combos...");
21560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
21561 13 combosread=true;
21562
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21563 13 box_out("okay.");
21564 13 box_eol();
21565 13 break;
21566
21567 case ID_COMBOALIASES:
21568
21569 //combo aliases
21570
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21571 {
21572 box_out("found.");
21573 box_eol();
21574 catchup=false;
21575 }
21576
21577 13 box_out("Reading Combo Aliases...");
21578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_comboaliases));
21579
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21580 13 box_out("okay.");
21581 13 box_eol();
21582 13 break;
21583
21584 case ID_CSETS:
21585
21586 //color data
21587
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21588 {
21589 box_out("found.");
21590 box_eol();
21591 catchup=false;
21592 }
21593
21594 13 box_out("Reading Color Data...");
21595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
21596
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21597 13 box_out("okay.");
21598 13 box_eol();
21599 13 break;
21600
21601 case ID_MAPS:
21602
21603 //maps
21604
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21605 {
21606 box_out("found.");
21607 box_eol();
21608 catchup=false;
21609 }
21610
21611 13 box_out("Reading Maps...");
21612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
21613 13 mapsread=true;
21614
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21615 13 box_out("okay.");
21616 13 box_eol();
21617 13 break;
21618
21619 case ID_DMAPS:
21620
21621 //dmaps
21622
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21623 {
21624 box_out("found.");
21625 box_eol();
21626 catchup=false;
21627 }
21628
21629 13 box_out("Reading DMaps...");
21630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21631
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21632 13 box_out("okay.");
21633 13 box_eol();
21634 13 break;
21635
21636 case ID_DOORS:
21637
21638 //door combo sets
21639
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21640 {
21641 box_out("found.");
21642 box_eol();
21643 catchup=false;
21644 }
21645
21646 13 box_out("Reading Doors...");
21647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21648
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21649 13 box_out("okay.");
21650 13 box_eol();
21651 13 break;
21652
21653 case ID_ITEMS:
21654
21655 //items
21656
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21657 {
21658 box_out("found.");
21659 box_eol();
21660 catchup=false;
21661 }
21662
21663 13 box_out("Reading Items...");
21664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21665
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21666
21667 13 box_out("okay.");
21668 13 box_eol();
21669 13 break;
21670
21671 case ID_WEAPONS:
21672
21673 //weapons
21674
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21675 {
21676 box_out("found.");
21677 box_eol();
21678 catchup=false;
21679 }
21680
21681 13 box_out("Reading Weapons...");
21682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
21683
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21684 13 box_out("okay.");
21685 13 box_eol();
21686 13 break;
21687
21688 case ID_COLORS:
21689
21690 //misc. colors
21691
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21692 {
21693 box_out("found.");
21694 box_eol();
21695 catchup=false;
21696 }
21697
21698 13 box_out("Reading Misc. Colors...");
21699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readmisccolors(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_colors));
21700
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21701 13 box_out("okay.");
21702 13 box_eol();
21703 13 break;
21704
21705 case ID_ICONS:
21706
21707 //game icons
21708
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21709 {
21710 box_out("found.");
21711 box_eol();
21712 catchup=false;
21713 }
21714
21715 13 box_out("Reading Game Icons...");
21716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readgameicons(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_icons));
21717
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21718 13 box_out("okay.");
21719 13 box_eol();
21720 13 break;
21721
21722 case ID_INITDATA:
21723
21724 //initialization data
21725
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21726 {
21727 box_out("found.");
21728 box_eol();
21729 catchup=false;
21730 }
21731
21732 13 box_out("Reading Init. Data...");
21733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
21734
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21735 13 box_out("okay.");
21736 13 box_eol();
21737
21738
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(keepall&&!get_bit(skip_flags, skip_subscreens))
21739 {
21740
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 8 times.
13 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21741 {
21742 8 setupsubscreens();
21743
21744
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 8 times.
4104 for(int32_t i=0; i<MAXDMAPS; ++i)
21745 {
21746 4096 int32_t type=DMaps[i].type&dmfTYPE;
21747
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4088 times.
4096 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21748 4096 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
21749 4096 }
21750 8 }
21751 13 }
21752
21753
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(keepall&&!get_bit(skip_flags, skip_sfx))
21754 {
21755 13 setupsfx();
21756 13 }
21757
21758
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(keepall&&!get_bit(skip_flags, skip_itemdropsets))
21759 {
21760 13 init_item_drop_sets();
21761 13 }
21762
21763
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(keepall&&!get_bit(skip_flags, skip_favorites))
21764 {
21765 13 init_favorites();
21766 13 }
21767
21768 13 break;
21769
21770 case ID_GUYS:
21771
21772 //guys
21773
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21774 {
21775 box_out("found.");
21776 box_eol();
21777 catchup=false;
21778 }
21779
21780 13 box_out("Reading Custom Guy Data...");
21781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
21782
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21783 13 box_out("okay.");
21784 13 box_eol();
21785 13 break;
21786
21787 case ID_HEROSPRITES:
21788
21789 //player sprites
21790
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21791 {
21792 box_out("found.");
21793 box_eol();
21794 catchup=false;
21795 }
21796
21797 13 box_out("Reading Custom Player Sprite Data...");
21798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readherosprites(f, &tempheader, keepall&&!get_bit(skip_flags, skip_herosprites));
21799
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21800 13 box_out("okay.");
21801 13 box_eol();
21802 13 break;
21803
21804 case ID_SUBSCREEN:
21805
21806 //custom subscreens
21807
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21808 {
21809 box_out("found.");
21810 box_eol();
21811 catchup=false;
21812 }
21813
21814 13 box_out("Reading Custom Subscreen Data...");
21815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readsubscreens(f, &tempheader, keepall&&!get_bit(skip_flags, skip_subscreens));
21816
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21817 13 box_out("okay.");
21818 13 box_eol();
21819 13 break;
21820
21821 case ID_FFSCRIPT:
21822
21823 //Freeform combo scripts
21824
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21825 {
21826 box_out("found.");
21827 box_eol();
21828 catchup=false;
21829 }
21830
21831 13 box_out("Reading FF Script Data...");
21832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readffscript(f, &tempheader, keepall&&!get_bit(skip_flags, skip_ffscript));
21833
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21834 13 box_out("okay.");
21835 13 box_eol();
21836 13 break;
21837
21838 case ID_SFX:
21839
21840 //SFX data
21841
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21842 {
21843 box_out("found.");
21844 box_eol();
21845 catchup=false;
21846 }
21847
21848 13 box_out("Reading SFX Data...");
21849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readsfx(f, &tempheader, keepall&&!get_bit(skip_flags, skip_sfx));
21850
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21851 13 box_out("okay.");
21852 13 box_eol();
21853 13 break;
21854
21855 case ID_MIDIS:
21856
21857 //midis
21858
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21859 {
21860 box_out("found.");
21861 box_eol();
21862 catchup=false;
21863 }
21864
21865 13 box_out("Reading Tunes...");
21866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
21867
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21868 13 box_out("okay.");
21869 13 box_eol();
21870 13 break;
21871
21872 case ID_CHEATS:
21873
21874 //cheat codes
21875
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21876 {
21877 box_out("found.");
21878 box_eol();
21879 catchup=false;
21880 }
21881
21882 13 box_out("Reading Cheat Codes...");
21883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
21884
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21885 13 box_out("okay.");
21886 13 box_eol();
21887 13 break;
21888
21889 case ID_ITEMDROPSETS:
21890
21891 //item drop sets
21892
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21893 {
21894 box_out("found.");
21895 box_eol();
21896 catchup=false;
21897 }
21898
21899 13 box_out("Reading Item Drop Sets...");
21900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_itemdropsets));
21901
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21902 13 box_out("okay.");
21903 13 box_eol();
21904 13 break;
21905
21906 case ID_FAVORITES:
21907
21908 //favorite combos and combo aliases
21909
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(catchup)
21910 {
21911 box_out("found.");
21912 box_eol();
21913 catchup=false;
21914 }
21915
21916 13 box_out("Reading Favorite Combos...");
21917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 ret=readfavorites(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_favorites));
21918
1/5
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
13 checkstatus(ret);
21919 13 box_out("okay.");
21920 13 box_eol();
21921 13 break;
21922
21923 default:
21924 if(!catchup)
21925 {
21926 box_out("Bad token! Searching...");
21927 box_eol();
21928 }
21929
21930 catchup=true;
21931 break;
21932 }
21933
21934
21935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 312 times.
312 if(catchup)
21936 {
21937 //section id
21938 section_id=(section_id<<8);
21939
21940 if(!p_getc(&tempbyte,f,true))
21941 {
21942 return qe_invalid;
21943 }
21944
21945 section_id+=tempbyte;
21946 }
21947
21948 else
21949 {
21950 //section id
21951
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 299 times.
312 if(!pack_feof(f))
21952 {
21953
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if(!p_mgetl(&section_id,f,true))
21954 {
21955 return qe_invalid;
21956 }
21957 299 }
21958 }
21959 }
21960 13 }
21961 else
21962 {
21963 //rules
21964 box_out("Reading Rules...");
21965 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21966 checkstatus(ret);
21967 box_out("okay.");
21968 box_eol();
21969
21970 //strings
21971 box_out("Reading Strings...");
21972 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21973 checkstatus(ret);
21974 box_out("okay.");
21975 box_eol();
21976
21977 //door combo sets
21978 box_out("Reading Doors...");
21979 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21980 checkstatus(ret);
21981 box_out("okay.");
21982 box_eol();
21983
21984 //dmaps
21985 box_out("Reading DMaps...");
21986 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21987 checkstatus(ret);
21988 box_out("okay.");
21989 box_eol();
21990
21991 // misc data
21992 box_out("Reading Misc. Data...");
21993 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21994 checkstatus(ret);
21995 box_out("okay.");
21996 box_eol();
21997
21998 //items
21999 box_out("Reading Items...");
22000 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
22001 checkstatus(ret);
22002 box_out("okay.");
22003 box_eol();
22004
22005 //weapons
22006 box_out("Reading Weapons...");
22007 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
22008 checkstatus(ret);
22009 box_out("okay.");
22010 box_eol();
22011
22012 //guys
22013 box_out("Reading Custom Guy Data...");
22014 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
22015 checkstatus(ret);
22016 box_out("okay.");
22017 box_eol();
22018
22019 //maps
22020 box_out("Reading Maps...");
22021 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
22022 mapsread=true;
22023 checkstatus(ret);
22024 box_out("okay.");
22025 box_eol();
22026
22027 //combos
22028 box_out("Reading Combos...");
22029 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
22030 combosread=true;
22031 checkstatus(ret);
22032 box_out("okay.");
22033 box_eol();
22034
22035 //color data
22036 box_out("Reading Color Data...");
22037 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
22038 checkstatus(ret);
22039 box_out("okay.");
22040 box_eol();
22041
22042 //tiles
22043 box_out("Reading Tiles...");
22044 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
22045 checkstatus(ret);
22046 box_out("okay.");
22047 box_eol();
22048
22049 //midis
22050 box_out("Reading Tunes...");
22051 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
22052 checkstatus(ret);
22053 box_out("okay.");
22054 box_eol();
22055
22056 //cheat codes
22057 box_out("Reading Cheat Codes...");
22058 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
22059 checkstatus(ret);
22060 box_out("okay.");
22061 box_eol();
22062
22063 //initialization data
22064 box_out("Reading Init. Data...");
22065 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
22066 checkstatus(ret);
22067 box_out("okay.");
22068 box_eol();
22069
22070 if(keepall&&!get_bit(skip_flags, skip_subscreens))
22071 {
22072 setupsubscreens();
22073
22074 for(int32_t i=0; i<MAXDMAPS; ++i)
22075 {
22076 int32_t type=DMaps[i].type&dmfTYPE;
22077 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22078 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
22079 }
22080 }
22081
22082 box_out("Setting Up Default Sound Effects...");
22083
22084 if(keepall&&!get_bit(skip_flags, skip_sfx))
22085 setupsfx();
22086
22087 box_out("okay.");
22088 box_eol();
22089
22090 //player sprites
22091 box_out("Reading Custom Player Sprite Data...");
22092 ret=readherosprites2(f, -1, 0, keepall&&!get_bit(skip_flags, skip_herosprites));
22093 checkstatus(ret);
22094 box_out("okay.");
22095 box_eol();
22096
22097 box_out("Setting Up Default Item Drop Sets...");
22098 ret=readitemdropsets(f, -1, 0, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22099 box_out("okay.");
22100 box_eol();
22101 }
22102
22103 13 init_spritelists();
22104
22105 // check data
22106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(f)
22107 {
22108 13 pack_fclose(f);
22109 13 }
22110
22111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(!oldquest)
22112 {
22113
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(exists(tmpfilename))
22114 {
22115 delete_file(tmpfilename);
22116 }
22117 13 }
22118
22119
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13 if(fixffcs && combosread && mapsread)
22120 {
22121 for(int32_t i=0; i<map_count; i++)
22122 {
22123 for(int32_t j=0; j<MAPSCRS; j++)
22124 {
22125 for(int32_t m=0; m<32; m++)
22126 {
22127 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22128 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22129 }
22130 }
22131 }
22132 }
22133
22134
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1 times.
13 if(get_bit(quest_rules, qr_CONTFULL_DEP))
22135 {
22136 1 set_bit(quest_rules, qr_CONTFULL_DEP, 0);
22137 1 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22138 1 zinit.cont_heart=100;
22139 1 zinit.start_heart=zinit.hc;
22140 1 }
22141
22142 13 box_out("Done.");
22143 13 box_eol();
22144 13 box_end(false);
22145
22146 // if (keepall==true||!get_bit(skip_flags, skip_header))
22147
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(keepall&&!get_bit(skip_flags, skip_header))
22148 {
22149 13 memcpy(Header, &tempheader, sizeof(tempheader));
22150 13 }
22151
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(keepall&&!get_bit(skip_flags, skip_zinfo))
22152 {
22153 13 ZI.copyFrom(tempzi);
22154 13 }
22155
22156
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(!keepall||get_bit(skip_flags, skip_maps))
22157 {
22158 map_count=old_map_count;
22159 }
22160
22161
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(!keepall||get_bit(skip_flags, skip_rules))
22162 {
22163 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22164 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22165 }
22166
22167
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if(!keepall||get_bit(skip_flags, skip_midis))
22168 {
22169 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22170 }
22171
22172
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(deletefilename[0] && exists(deletefilename))
22173 {
22174 13 delete_file(deletefilename);
22175 13 }
22176
22177 //Debug FFCore.quest_format[]
22178 13 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22179 13 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22180 13 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22181 13 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22182 13 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22183 13 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22184 13 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22185 13 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22186 13 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22187 13 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22188 13 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22189 13 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22190 13 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22191 13 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22192 13 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22193 13 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22194 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22195 13 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22196 13 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22197 13 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22198 13 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22199 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22200 13 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22201 13 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22202 13 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22203 13 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22204 13 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22205 13 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22206 13 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22207 13 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22208 //Print metadata for versions under 2.10 here. Bleah.
22209
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if( FFCore.quest_format[vZelda] < 0x210 )
22210 {
22211 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22212
22213 switch(FFCore.quest_format[vZelda])
22214 {
22215 case 0x193:
22216 {
22217 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22218 }
22219 case 0x192:
22220 {
22221 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22222 }
22223 case 0x190:
22224 {
22225 zprint2("Last saved in ZC Editor Version: 1.90");
22226 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22227 else zprint2("\n");
22228 break;
22229 }
22230 case 0x188:
22231 {
22232 zprint2("Last saved in ZC Editor Version: 1.88");
22233 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22234 else zprint2("\n");
22235 break;
22236 }
22237 case 0x187:
22238 {
22239 zprint2("Last saved in ZC Editor Version: 1.87");
22240 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22241 else zprint2("\n");
22242 break;
22243 }
22244 case 0x186:
22245 {
22246 zprint2("Last saved in ZC Editor Version: 1.86");
22247 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22248 else zprint2("\n");
22249 break;
22250 }
22251 case 0x185:
22252 {
22253 zprint2("Last saved in ZC Editor Version: 1.85");
22254 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22255 else zprint2("\n");
22256 break;
22257 }
22258 case 0x184:
22259 {
22260 zprint2("Last saved in ZC Editor Version: 1.84");
22261 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22262 else zprint2("\n");
22263 break;
22264 }
22265 case 0x183:
22266 {
22267 zprint2("Last saved in ZC Editor Version: 1.83");
22268 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22269 else zprint2("\n");
22270 break;
22271 }
22272 case 0x182:
22273 {
22274 zprint2("Last saved in ZC Editor Version: 1.82");
22275 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22276 else zprint2("\n");
22277 break;
22278 }
22279 case 0x181:
22280 {
22281 zprint2("Last saved in ZC Editor Version: 1.81");
22282 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22283 else zprint2("\n");
22284 break;
22285 }
22286 case 0x180:
22287 {
22288 zprint2("Last saved in ZC Editor Version: 1.80");
22289 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22290 else zprint2("\n");
22291 break;
22292 }
22293 default:
22294 {
22295 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22296 }
22297 }
22298 }
22299
22300 13 return qe_OK;
22301
22302 invalid:
22303 box_out("error.");
22304 box_eol();
22305 box_end(true);
22306
22307 if(f)
22308 {
22309 pack_fclose(f);
22310 }
22311
22312 if(!oldquest)
22313 {
22314 if(exists(tmpfilename))
22315 {
22316 delete_file(tmpfilename);
22317 }
22318
22319 if(deletefilename[0] && exists(deletefilename))
22320 {
22321 delete_file(deletefilename);
22322 }
22323 }
22324
22325 return qe_invalid;
22326
22327 13 }
22328
22329 13 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool compressed, bool encrypted, bool keepall, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22330 {
22331 13 loading_qst_name = filename;
22332 13 loading_qst_num = qst_num;
22333 13 loadquest_report = report;
22334 13 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, compressed, encrypted, keepall, skip_flags,printmetadata);
22335 13 load_tmp_zi = NULL;
22336 13 loading_qst_name = NULL;
22337 13 loadquest_report = false;
22338 13 loading_qst_num = 0;
22339 13 return ret;
22340 }
22341 /*** end of qst.cc ***/
22342
22343